Mark fields used in form with @Persist("flash") annotation, so they won't be
cleared if you catch some error during validation. These fields will be
cleared after second reload of page, and that will supply your needs I
think. If you need to stay on that page after the form is successfully
submitted, use ComponentResources in onSuccess() to clear persistent field
values.

Example:

@Persist("flash")
private String username;

@Inject
private ComponentResources _componentResources;

....

Object onSuccess() {
    ...
    _componentResources.discardPersistentFieldChanges();
   return null; //to stay on same page after success. Ignore this usage of
ComponentResources if you
                    //     redirect to another page (99% of cases).
}
 

Mihaela Pilon wrote:
> 
> Hi,
> 
> I have a problem where my form field inputs are always cleared after
> my "success" event handling.
> 
> It's all fine when I can check my inputs prior to "success", such as
> inside "validateForm" handler, but sometimes there is no error in
> form, but is raised by service layer in form of exception, and I want
> to catch it and stay on same page with error shown. Unfortunately in
> that case form inputs are cleared. It seems that Tapestry assumes that
> once the "success" handler is reached that everything will be fine
> afterwards, whereas it doesn't have to.
> 
> How do you handle these situations folks, I'm sure this isn't something
> unusual?
> 
> -MP
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Form-field-inputs-automatically-cleared-when-success-reached-tp3266860p3267019.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to