You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Christian Huber <hu...@butterbrot.org> on 2011/07/11 01:00:39 UTC
Skip validation on nested form's form level validators
Hi all,
I have two forms nested within each other (wicket 1.4.17). The inner
form adds data to the model of the outer form via ajax when it's button
is pressed while the outer form saves the data to the database when the
outer form's submit button is pressed.
Both forms have validators attacehd to them and their components. and of
course the inner form's validators must not be executed when the outer
form is submitted. Having the inner form implement
IFormVisitorParticipant and then check if the submitting button was it's
own avoids the inner form's component's validators to be executed. But
validators applied to the inner form directly (e.g. EqualInputValidators
etc.) are still executed and in my case causing the request to die
horribly because the requred data just is not there.
I was looking for an elegant way to solve this but since all validate
methods in the hierarchy are final I cannot hook any code into the
form's on validation cycle. The method onValidate is not called (I guess
that is because the form is validated as the outer form's child). All
other methods that allow me to achieve the deisred behavior (like
isEnabled) are too general cause side effects like disabling the form.
At the moment the only way I can think of is to disable default form
processing and then call the validators manually which is not very
appealing to me.
Is there another way how this can be done?
Cheers,
Chris
--
The Sanity Resort <http://sanityresort.blogspot.com/>
Re: Skip validation on nested form's form level validators
Posted by Martin Grigorov <mg...@apache.org>.
Christian,
Can you try the patch in https://issues.apache.org/jira/browse/WICKET-3899 ?
On Mon, Jul 11, 2011 at 10:02 PM, Christian Huber <hu...@butterbrot.org> wrote:
> Hi,
>
> well i _could_ decouple the two forms but that would kinda break my usecase
> and also the layout due to the changed component hierarchy.
>
> Removing and readding the validators does not strike me as a good idea
> though, that would mean that the outer form would have knowledge about the
> internals of the inner form, which would break not only cohesion but also
> the law of demeter.
>
> I was thinking that since there is a defined way to let a form decide for
> itself if it's component's validators should be executed that there might
> also be a similar way to do this for form level validators. But it seems
> that this is not the case. So I guess I will try disabling the default form
> processing on the outer form and call it's component's validators manually
> in the onsubmit method of the corresponding button.
>
> Anyway thanks for your time.
>
> Am 11.07.2011 15:01, schrieb Andrea Del Bene:
>>
>> Hi,
>>
>> why don't simply put the inner form out of the outer one? Anyway, you
>> could remove inner form's validators before the outer form is submitted and
>> add them again when submit process is over (onFormSubmitted() )
>>>
>>> Hi all,
>>>
>>> I have two forms nested within each other (wicket 1.4.17). The inner form
>>> adds data to the model of the outer form via ajax when it's button is
>>> pressed while the outer form saves the data to the database when the outer
>>> form's submit button is pressed.
>>>
>>> Both forms have validators attacehd to them and their components. and of
>>> course the inner form's validators must not be executed when the outer form
>>> is submitted. Having the inner form implement IFormVisitorParticipant and
>>> then check if the submitting button was it's own avoids the inner form's
>>> component's validators to be executed. But validators applied to the inner
>>> form directly (e.g. EqualInputValidators etc.) are still executed and in my
>>> case causing the request to die horribly because the requred data just is
>>> not there.
>>>
>>> I was looking for an elegant way to solve this but since all validate
>>> methods in the hierarchy are final I cannot hook any code into the form's on
>>> validation cycle. The method onValidate is not called (I guess that is
>>> because the form is validated as the outer form's child). All other methods
>>> that allow me to achieve the deisred behavior (like isEnabled) are too
>>> general cause side effects like disabling the form. At the moment the only
>>> way I can think of is to disable default form processing and then call the
>>> validators manually which is not very appealing to me.
>>>
>>> Is there another way how this can be done?
>>>
>>> Cheers,
>>> Chris
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
> --
> The Sanity Resort <http://sanityresort.blogspot.com/>
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Skip validation on nested form's form level validators
Posted by Christian Huber <hu...@butterbrot.org>.
Hi,
well i _could_ decouple the two forms but that would kinda break my
usecase and also the layout due to the changed component hierarchy.
Removing and readding the validators does not strike me as a good idea
though, that would mean that the outer form would have knowledge about
the internals of the inner form, which would break not only cohesion but
also the law of demeter.
I was thinking that since there is a defined way to let a form decide
for itself if it's component's validators should be executed that there
might also be a similar way to do this for form level validators. But it
seems that this is not the case. So I guess I will try disabling the
default form processing on the outer form and call it's component's
validators manually in the onsubmit method of the corresponding button.
Anyway thanks for your time.
Am 11.07.2011 15:01, schrieb Andrea Del Bene:
> Hi,
>
> why don't simply put the inner form out of the outer one? Anyway, you
> could remove inner form's validators before the outer form is
> submitted and add them again when submit process is over
> (onFormSubmitted() )
>> Hi all,
>>
>> I have two forms nested within each other (wicket 1.4.17). The inner
>> form adds data to the model of the outer form via ajax when it's
>> button is pressed while the outer form saves the data to the database
>> when the outer form's submit button is pressed.
>>
>> Both forms have validators attacehd to them and their components. and
>> of course the inner form's validators must not be executed when the
>> outer form is submitted. Having the inner form implement
>> IFormVisitorParticipant and then check if the submitting button was
>> it's own avoids the inner form's component's validators to be
>> executed. But validators applied to the inner form directly (e.g.
>> EqualInputValidators etc.) are still executed and in my case causing
>> the request to die horribly because the requred data just is not there.
>>
>> I was looking for an elegant way to solve this but since all validate
>> methods in the hierarchy are final I cannot hook any code into the
>> form's on validation cycle. The method onValidate is not called (I
>> guess that is because the form is validated as the outer form's
>> child). All other methods that allow me to achieve the deisred
>> behavior (like isEnabled) are too general cause side effects like
>> disabling the form. At the moment the only way I can think of is to
>> disable default form processing and then call the validators manually
>> which is not very appealing to me.
>>
>> Is there another way how this can be done?
>>
>> Cheers,
>> Chris
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
--
The Sanity Resort <http://sanityresort.blogspot.com/>
Re: Skip validation on nested form's form level validators
Posted by Andrea Del Bene <ad...@ciseonweb.it>.
Hi,
why don't simply put the inner form out of the outer one? Anyway, you
could remove inner form's validators before the outer form is submitted
and add them again when submit process is over (onFormSubmitted() )
> Hi all,
>
> I have two forms nested within each other (wicket 1.4.17). The inner
> form adds data to the model of the outer form via ajax when it's
> button is pressed while the outer form saves the data to the database
> when the outer form's submit button is pressed.
>
> Both forms have validators attacehd to them and their components. and
> of course the inner form's validators must not be executed when the
> outer form is submitted. Having the inner form implement
> IFormVisitorParticipant and then check if the submitting button was
> it's own avoids the inner form's component's validators to be
> executed. But validators applied to the inner form directly (e.g.
> EqualInputValidators etc.) are still executed and in my case causing
> the request to die horribly because the requred data just is not there.
>
> I was looking for an elegant way to solve this but since all validate
> methods in the hierarchy are final I cannot hook any code into the
> form's on validation cycle. The method onValidate is not called (I
> guess that is because the form is validated as the outer form's
> child). All other methods that allow me to achieve the deisred
> behavior (like isEnabled) are too general cause side effects like
> disabling the form. At the moment the only way I can think of is to
> disable default form processing and then call the validators manually
> which is not very appealing to me.
>
> Is there another way how this can be done?
>
> Cheers,
> Chris
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org