You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nicholas Lesiecki <nl...@vmsinfo.com> on 2005/02/02 18:36:17 UTC

RE: Turn off validation for some form submissions?

Thanks for the reply Erik! Here's the scenario

--- begin plaintext mockup ---

Save your work: [Save Button]

Length : [<A ValidField that has an attached validator required, min, max>] 

---my component---
Search for Products [<A text field>] [Search Button * ]
[select multiple for showing search results]

---end my component---


--- end plaintext mockup ---

So when I hit "Search Button" I don't want the Length field to validate.
When I hit "Save Button" I do. Search Button has a listener attached to my
component, Save Button has a listener attached to the page.

Your suggestion sounds intriguing, but how could I access the other
components in the form from within my component? And doesn't validation run
as the component is being rewound, making dynamic disabling which happens in
a listener non-viable?

My best guess for a solution is to Subclass ValidField and also Submit.
CustomSubmit would have a new option like "disable validation". This option
would submit a hidden request parameter. CustomValidField would check for
this field in the request and avoid all the validation logic if it was
present.

My proposed solution seems sleazy, but it's all I can come up with ATM. Is
there a better way?

Cheers,
Nick

-----Original Message-----
From: Erik Hatcher [mailto:erik@ehatchersolutions.com] 
Sent: Sunday, January 30, 2005 10:21 AM
To: Tapestry users
Subject: Re: Turn off validation for some form submissions?


On Jan 30, 2005, at 11:20 AM, Nicholas Lesiecki wrote:
> I have a number of components on my page, including custom components 
> that let you run a search on a database list in order to select a 
> property.
> The
> search is accomplished by a listener method on a submit component 
> that's part of my custom component. Since the form won't be complete 
> until the user has picked several selections from these search boxes, 
> I'd like to suspend validation on the other components of the form 
> until the final, "real"
> form
> submission (when the user indicates that they'd like their changes 
> saved).
> Does Tapestry offer any way of accomplishing this other than writing 
> all the validation checks manually in the form's submit handler?

Sure.  I presume these other components support the use of an IValidator?
If so, you can control whether they are required or not or any other factors
relating to them dynamically.  So suspending the validation may be as simple
as setRequired(false) on a ValidField's IValidator.

Does that help?  Or should I elaborate?  Let us know some specifics on what
components you're referring to and how you have the validation wired in now.

	Erik


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



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