You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by meduolis <me...@gmail.com> on 2012/04/30 09:45:29 UTC

Setting value to object when validation failed

Hello this is quick start project which reproduces my case"
http://apache-wicket.1842946.n4.nabble.com/file/n4597599/project.zip
project.zip 

The problem is, that I cannot set value for object after form validation
fails.

How to reproduce:
1. Startup my quicstart app;
2. Do not fill required field and press Save;
4. Validation error occurs, that field is required;
3. Press "Set name"; (this should set first name to "John Doe" and refresh);

Expected result: input field sets to "John Doe";

Actual result: nothing happens;

Does anyone knows what I am doing wrong? :)

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Setting-value-to-object-when-validation-failed-tp4597599.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Setting value to object when validation failed

Posted by meduolis <me...@gmail.com>.
OK, I got the idea :), thanks a lot for helping.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Setting-value-to-object-when-validation-failed-tp4597599p4599127.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Setting value to object when validation failed

Posted by Dan Retzlaff <dr...@gmail.com>.
Check out Form#clearInput() which calls FormComponent#clearInput() on all
of its components. You can do similiar, but incorporate
FormComponent#hasErrorMessage() so you don't also reset fields with valid
input.

On Mon, Apr 30, 2012 at 11:11 AM, meduolis <me...@gmail.com> wrote:

> This solves my problem. Is there any way to collect all components that
> fails?
> or I just have to check each separate component if it has any feedback
> messages (level > ERROR) and then clear it's value by myself?
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Setting-value-to-object-when-validation-failed-tp4597599p4598947.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Setting value to object when validation failed

Posted by meduolis <me...@gmail.com>.
This solves my problem. Is there any way to collect all components that
fails?
or I just have to check each separate component if it has any feedback
messages (level > ERROR) and then clear it's value by myself?


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Setting-value-to-object-when-validation-failed-tp4597599p4598947.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Setting value to object when validation failed

Posted by Dan Retzlaff <dr...@gmail.com>.
Generally when a field validation fails, the user's raw input is
re-rendered instead of the original model value. This lets the user correct
his input instead of retyping the whole thing. Since this is not the
behavior you want, you can call firstName.clearInput() in your onError().

On Mon, Apr 30, 2012 at 12:45 AM, meduolis <me...@gmail.com> wrote:

> Hello this is quick start project which reproduces my case"
> http://apache-wicket.1842946.n4.nabble.com/file/n4597599/project.zip
> project.zip
>
> The problem is, that I cannot set value for object after form validation
> fails.
>
> How to reproduce:
> 1. Startup my quicstart app;
> 2. Do not fill required field and press Save;
> 4. Validation error occurs, that field is required;
> 3. Press "Set name"; (this should set first name to "John Doe" and
> refresh);
>
> Expected result: input field sets to "John Doe";
>
> Actual result: nothing happens;
>
> Does anyone knows what I am doing wrong? :)
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Setting-value-to-object-when-validation-failed-tp4597599.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>