You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Klaus Kopruch <kl...@materna.de> on 2009/12/08 10:15:10 UTC
Cross field validation in a component
Hello *
I have a component DateSelector which must be in a form. DateSelector
contains 3 Select components.
My question is, how can I perform cross-field validation in DateSelector? As
far as I see, there is no event which the component gets which I can use to
perform this task. DateSelector gets the 3 VALIDATE events from the 3
embedded Select components but what I need is an event which will be sent to
DateSelector after the 3 VALIDATE events, because not till then the 3 values
from the 3 embedded Select components are set.
So, what I need in my component is a kind of VALIDATE_FORM and also a
SUCCESS event (in order to set the resulting value from the 3 values).
Does anybody know, how a component can get those kind of events?
Thanks
Klaus
--
View this message in context: http://old.nabble.com/Cross-field-validation-in-a-component-tp26690823p26690823.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Cross field validation in a component
Posted by Klaus Kopruch <kl...@materna.de>.
Hi Juan,
thank you for this hint. I'll try it when I need it.
Up to now, I could work around that problem but not very elegant.
Regards, Klaus
Juan Isern wrote:
>
> Hi Klaus,
>
> I've been facing the same exact problem with validations when also
> developing a similar component (maybe this should be taken as a suggestion
> for the tapestry developers to include a more traditional date field...)
>
> What I've found out so far is that you can inject a FormSupport object
> that has a defer() method taking as its first argument a command whose
> execution will be postponed until the wrapping form is submitted. I think
> that meets our requirement.
>
> The problem is that when that deferred action is executed, the component
> is in a "weird" state: for instance, it happens to me that all the
> component state is nullified.
>
> Please check it out, maybe it works for you. It can't be THIS hard!
>
> Regards - Juan
>
--
View this message in context: http://old.nabble.com/Cross-field-validation-in-a-component-tp26690823p28001350.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Cross field validation in a component
Posted by Juan Isern <ju...@gmail.com>.
Hi Klaus,
I've been facing the same exact problem with validations when also
developing a similar component (maybe this should be taken as a suggestion
for the tapestry developers to include a more traditional date field...)
What I've found out so far is that you can inject a FormSupport object that
has a defer() method taking as its first argument a command whose execution
will be postponed until the wrapping form is submitted. I think that meets
our requirement.
The problem is that when that deferred action is executed, the component is
in a "weird" state: for instance, it happens to me that all the component
state is nullified.
Please check it out, maybe it works for you. It can't be THIS hard!
Regards - Juan
Klaus Kopruch wrote:
>
> Hello *
>
> I have a component DateSelector which must be in a form. DateSelector
> contains 3 Select components.
>
> My question is, how can I perform cross-field validation in DateSelector?
> As far as I see, there is no event which the component gets which I can
> use to perform this task. DateSelector gets the 3 VALIDATE events from the
> 3 embedded Select components but what I need is an event which will be
> sent to DateSelector after the 3 VALIDATE events, because not till then
> the 3 values from the 3 embedded Select components are set.
>
> So, what I need in my component is a kind of VALIDATE_FORM and also a
> SUCCESS event (in order to set the resulting value from the 3 values).
>
> Does anybody know, how a component can get those kind of events?
>
> Thanks
>
> Klaus
>
--
View this message in context: http://old.nabble.com/Cross-field-validation-in-a-component-tp26690823p28000661.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Cross field validation in a component
Posted by Juan Isern <ju...@gmail.com>.
Inheriting from AbstractField and doing something like this finally worked
wonders for me:
@Override
protected void processSubmission(String elementName) {
formSupport.defer(new Runnable() {
public void run() {
// do validations, commit values, etc.
}
});
}
That's a pretty solution and works okay. Note that defer() has to be invoked
in processSubmission(), otherwise it won't work
Klaus Kopruch wrote:
>
> Hello *
>
> I have a component DateSelector which must be in a form. DateSelector
> contains 3 Select components.
>
> My question is, how can I perform cross-field validation in DateSelector?
> As far as I see, there is no event which the component gets which I can
> use to perform this task. DateSelector gets the 3 VALIDATE events from the
> 3 embedded Select components but what I need is an event which will be
> sent to DateSelector after the 3 VALIDATE events, because not till then
> the 3 values from the 3 embedded Select components are set.
>
> So, what I need in my component is a kind of VALIDATE_FORM and also a
> SUCCESS event (in order to set the resulting value from the 3 values).
>
> Does anybody know, how a component can get those kind of events?
>
> Thanks
>
> Klaus
>
--
View this message in context: http://old.nabble.com/Cross-field-validation-in-a-component-tp26690823p28287235.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org