Hi!
Is there a bug in handling the first listView row submitted using
WicketTester/FormTester?
Regardless of the original values displayed on the first row of the
listView, the textField.getConvertedInput() and
checkbox.getConvertedInput() return null and false values at the form
validator, respectively.
If I surpass the validator, the form is submitted just fine. It is
only in the validator where the problem occurs and it is on the first
row only (i.e., elements "listView:0:todo" and
"listView:0:description"). Other rows submitted using the FormTester
seem to work just fine so far.
Is this a bug or am I using it improperly? Here is the test code; the
rest of the code remains the same as previously in the thread "Tabular
form validation problem with checkboxes" (all the previous advices
taken, though):
public void testThatCheckingARowButLeavingTheDescriptionEmptyResultsInError()
{
tester.startPage(Todos.class);
FormTester formTester = tester.newFormTester(Todos.TODO_FORM);
formTester.setValue("listView:3:todo", "true"); // I do not touch
row 0 but those items' default values are not received by the
validator
formTester.submit();
tester.assertRenderedPage(Todos.class);
String testString = new
Localizer().getString("checked_but_description_missing", new Todos());
System.out.println("testString=" + testString);
tester.assertErrorMessages(new String[] { testString, } );
}
**
Martin
2008/2/21, Igor Vaynberg <[EMAIL PROTECTED]>:
> this line: textRequired = (Boolean) checkBox.getModelObject(); should not work
>
> you are inside a validator, that means models haven not been updated
> yet. models are only updated once all type conversion/validation
> succeeds.
>
> inside validators you should use formcomponent.getconvertedinput() to
> read the value that will be put into the model if validators succeed.
>
> -igor
>
>
> On Wed, Feb 20, 2008 at 3:30 PM, Martin Makundi
>
> <[EMAIL PROTECTED]> wrote:
>
> > > a proper solution would be to use a validator or a formvalidator to do
> > > this. generally you never iterate over components to do validation in
> > > wicket. we have good plugin points for you in the form workflow.
> >
> > Judging from the performance of the checkbox, I have a wrong plugin
> > point for the validator. How would you put it?
> >
> >
> > > you didnt show the part of code that generates the list...
> > > > it is just a dummy list of new todo items.
> > > they are unique but you are using a listview? so what you have is not
> > > a list at all, it is a collection of random items.
> > > perhaps listview is not what you want. if you keep regenerating items
> every request
> >
> > They are not random. Here is the code generating the items:
> > List<Todo> linkedTodos = new LinkedList<Todo>();
> > {
> > Todo todo = new Todo();
> > todo.setDescription("Dummy");
> > todo.setSelected(true);
> > todo.setTodoDate(Convert.toDate("1.1.2008");
> > linkedTodos.add(todo);
> > }
> > // ... and I have repeated a number of these ... say 7 pcs
> > return linkedTodos;
> >
> > The page uses a linkedTodos "singleton" in the sence that the list is
> > generated only the first time the page is loaded. So they are not
> > random.
> >
> >
> > > > Is there a bug with the checkbox?
> > > doubt it
> >
> > Well.. the validator fails to receive the submitted checkbox state.
> > Did I attach the validator improperly? Or should I read the checkbox
> > value in some other way? The checkbox state submitted from the browser
> > is not received by the validator using the code I posted before. The
> > textfields function properly, but the checkboxes seem to somehow be
> > disconnected... they sometimes change state according to the selection
> > in the browser window, sometimes not. Mostly not ;) Odd times? Very
> > strange.
> >
> >
> >
> > **
> > Martin
> >
>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]