Re: Testing DataTable simulating click on link, checkbox etc...
i m working on the datatable and provide links to every link through panel but when click on it it fetch error that wicket id of link not found in FF but working fine inIE -- View this message in context: http://old.nabble.com/Testing-DataTable-simulating-click-on-link%2C-checkbox-etc...-tp17533033p27929715.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Testing DataTable simulating click on link, checkbox etc...
On Fri, May 30, 2008 at 4:54 AM, Timo Rantalaiho <[EMAIL PROTECTED]> wrote: > On Thu, 29 May 2008, Daniele Dellafiore wrote: >> umm, but in example above, what column and row number are grabbed? >> >> there is a way to show the complete graph of a wicket page hierarchy? > > Yes there is, WicketTester.debugComponentTrees() and I > think some other way as well. > > However, to get to your checkboxes inside the repeater, I > recommend using a visitor > >wicketTester.getLastRenderedPage().visitChildren(CheckBox.class, new >IVisitor() { >... >}); > > instead of relying on the component path, which is very > fragile. (Direct component path changes when the component > hierarchy changes, for example if you need to make some div > of the hierarchy a Wicket component. Repeaters might have > different number of items, the sorting may change etc.) > > jdave-wicket has the visitor stuff built-in, and you can > also select the component based on its model object > > CheckBox windShieldSelection = > selectFirst(CheckBox.class).which(is(windShield)).from(context); > wicketTester.executeAjaxEvent(windShieldSelection, "onclick"); > > or > > List allCheckBoxes = selectAll(CheckBox.class).from(context); these seem great, a way to write code I like: intentional :) thanks, i will try jdave and friends. -- Daniele Dellafiore http://blog.ildella.net/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing DataTable simulating click on link, checkbox etc...
On Thu, 29 May 2008, Daniele Dellafiore wrote: > umm, but in example above, what column and row number are grabbed? > > there is a way to show the complete graph of a wicket page hierarchy? Yes there is, WicketTester.debugComponentTrees() and I think some other way as well. However, to get to your checkboxes inside the repeater, I recommend using a visitor wicketTester.getLastRenderedPage().visitChildren(CheckBox.class, new IVisitor() { ... }); instead of relying on the component path, which is very fragile. (Direct component path changes when the component hierarchy changes, for example if you need to make some div of the hierarchy a Wicket component. Repeaters might have different number of items, the sorting may change etc.) jdave-wicket has the visitor stuff built-in, and you can also select the component based on its model object CheckBox windShieldSelection = selectFirst(CheckBox.class).which(is(windShield)).from(context); wicketTester.executeAjaxEvent(windShieldSelection, "onclick"); or List allCheckBoxes = selectAll(CheckBox.class).from(context); Also note that repeaters create their child items recently in onBeforeRender. WicketTester calls beforeRender() in startComponent to achieve this, but if your component changes state during the test so that the children should be re-created, you must call beforeRender explicitly on your repeater. Best wishes, Timo -- Timo Rantalaiho Reaktor Innovations Oyhttp://www.ri.fi/ > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing DataTable simulating click on link, checkbox etc...
Im not that familiar with the defaultdatatable. But yes you should add row and column numbers to the path. If doing it a bit more strictly you would probably get the datatable and iterate through it, or generate the numbers by getting the data behind. For debug purposes there aree both the debugcomponent hieracy and another method in wicket tester. And yes the wicket team are aware of this(not so useability friendly things), and I think they will do something about it in 1.5 Daniele Dellafiore wrote: On Thu, May 29, 2008 at 1:03 PM, Nino Saturnino Martinez Vazquez Wael <[EMAIL PROTECTED]> wrote: Could'nt you do one of two things: 1. Give the selector the fully path, something like :"tabel:row:column:checkpoxpanel:check" 2. Grab the check by using the full path like above and set the model on it.. umm, but in example above, what column and row number are grabbed? there is a way to show the complete graph of a wicket page hierarchy? Daniele Dellafiore wrote: Hi. I want to unit test a DefaultDataTable that have a column with some check boxes To achieve this, I have a panel defined as: and the table is simply: [Table] and I add this column: AbstractColumn checkBoxColumn = new AbstractColumn(new Model("Select")) { @Override public void populateItem(Item cellItem, String componentId, IModel rowModel) { cellItem.add(new CheckBoxPanel(componentId, rowModel)); } }; it works and all but I do not know how to unit test the code. The problem is to select a desired checkBox via WicketTester. I have the same problem if I have a link in the table: how to simulate the click on, say, link at row 5, column 1? Thanks for advices. -- -Wicket for love Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -Wicket for love Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing DataTable simulating click on link, checkbox etc...
On Thu, May 29, 2008 at 1:03 PM, Nino Saturnino Martinez Vazquez Wael <[EMAIL PROTECTED]> wrote: > Could'nt you do one of two things: > > 1. Give the selector the fully path, something like > :"tabel:row:column:checkpoxpanel:check" > 2. Grab the check by using the full path like above and set the model > on it.. umm, but in example above, what column and row number are grabbed? there is a way to show the complete graph of a wicket page hierarchy? > > > Daniele Dellafiore wrote: >> >> Hi. >> >> I want to unit test a DefaultDataTable that have a column with some check >> boxes >> To achieve this, I have a panel defined as: >> >> >> >> >> >> and the table is simply: >> >> [Table] >> >> and I add this column: >> >>AbstractColumn checkBoxColumn = new AbstractColumn(new >> Model("Select")) { >>@Override >>public void populateItem(Item cellItem, String >> componentId, IModel >> rowModel) { >>cellItem.add(new CheckBoxPanel(componentId, >> rowModel)); >>} >>}; >> >> it works and all but I do not know how to unit test the code. >> >> The problem is to select a desired checkBox via WicketTester. >> I have the same problem if I have a link in the table: how to simulate >> the click on, say, link at row 5, column 1? >> >> Thanks for advices. >> >> > > -- > -Wicket for love > > Nino Martinez Wael > Java Specialist @ Jayway DK > http://www.jayway.dk > +45 2936 7684 > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Daniele Dellafiore http://blog.ildella.net/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing DataTable simulating click on link, checkbox etc...
Could'nt you do one of two things: 1. Give the selector the fully path, something like :"tabel:row:column:checkpoxpanel:check" 2. Grab the check by using the full path like above and set the model on it.. Daniele Dellafiore wrote: Hi. I want to unit test a DefaultDataTable that have a column with some check boxes To achieve this, I have a panel defined as: and the table is simply: [Table] and I add this column: AbstractColumn checkBoxColumn = new AbstractColumn(new Model("Select")) { @Override public void populateItem(Item cellItem, String componentId, IModel rowModel) { cellItem.add(new CheckBoxPanel(componentId, rowModel)); } }; it works and all but I do not know how to unit test the code. The problem is to select a desired checkBox via WicketTester. I have the same problem if I have a link in the table: how to simulate the click on, say, link at row 5, column 1? Thanks for advices. -- -Wicket for love Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Testing DataTable simulating click on link, checkbox etc...
Hi. I want to unit test a DefaultDataTable that have a column with some check boxes To achieve this, I have a panel defined as: and the table is simply: [Table] and I add this column: AbstractColumn checkBoxColumn = new AbstractColumn(new Model("Select")) { @Override public void populateItem(Item cellItem, String componentId, IModel rowModel) { cellItem.add(new CheckBoxPanel(componentId, rowModel)); } }; it works and all but I do not know how to unit test the code. The problem is to select a desired checkBox via WicketTester. I have the same problem if I have a link in the table: how to simulate the click on, say, link at row 5, column 1? Thanks for advices. -- Daniele Dellafiore http://blog.ildella.net/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]