You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Steve Shucker <ss...@vmsinfo.com> on 2007/06/22 19:54:47 UTC

Conditional validation

Is there any way to configure validation so that a validator only runs 
for a specific submit method?

My situation is that I have a page with a few checkboxes and some 
linksubmits on it.  There's also a popup dialog box with some other form 
controls and a submit button.  I need everything in one form because the 
checkbox states should be persisted even when the popup dialog is 
submitted.  However, the validation for the controls in the dialog 
should only be performed when the submit button in the dialog is clicked.

My options as I see them:
- find a way to tie a control's validation to a specific submit method 
(what I'd prefer)
- validate manually in the listener method (loses client-side 
validation, requires more code)
- use a separate form with an async submit for the popup (may work, but 
then I'd have to return some javascript to submit the main page and 
redirect)
- change the submitType to refresh on the LinkSubmits in the main page 
so that only the the popup dialog's submit triggers validation.  I'm not 
sure if this would work at all, and I don't like it because it's a 
yes/no solution rather than letting me choose a set of controls to validate.

-Steve

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


RE: Conditional validation

Posted by Michael Sims <mi...@crye-leike.com>.
Steve Shucker wrote:
> Http only submits one set of form data.  If I have two forms, only the
> data from the form I submit is transmitted back to the server.
> Tapestry wouldn't receive the other information I want to persist.
> An async submit would get around this by not re-rendering the page to
> avoid losing the other state.

If you mark your properties as @Persist("client"), Tapestry will include their state
as hidden form fields in all forms on your page, so no matter which form is
submitted, you won't lose the state of the others.  If you mark them as
@Persist("session") they will be stored in the HttpSession; either way they will be
persisted.  I'm not actually using this feature in my app yet, but I have tested it
and it does work...


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


Re: Conditional validation

Posted by Steve Shucker <ss...@vmsinfo.com>.
Http only submits one set of form data.  If I have two forms, only the 
data from the form I submit is transmitted back to the server.  Tapestry 
wouldn't receive the other information I want to persist.  An async 
submit would get around this by not re-rendering the page to avoid 
losing the other state.

-Steve

Michael Sims wrote:
> Steve Shucker wrote:
>   
>> I need everything in one form
>> because the checkbox states should be persisted even when the popup
>> dialog is submitted.
>>     
> [...]
>   
>> My options as I see them:
>>     
> [...]
>   
>> - use a separate form with an async submit for the popup (may work,
>> but then I'd have to return some javascript to submit the main page
>> and redirect)
>>     
>
> Why not use a separate form, and mark the properties used by your forms with the
> @Persist annotation (either client or session)?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>   

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


RE: Conditional validation

Posted by Michael Sims <mi...@crye-leike.com>.
Steve Shucker wrote:
> I need everything in one form
> because the checkbox states should be persisted even when the popup
> dialog is submitted.
[...]
> My options as I see them:
[...]
> - use a separate form with an async submit for the popup (may work,
> but then I'd have to return some javascript to submit the main page
> and redirect)

Why not use a separate form, and mark the properties used by your forms with the
@Persist annotation (either client or session)?


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