You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Robert Dahlström <ro...@ongame.com> on 2011/03/30 14:45:53 UTC
Nested forms and conditional validation
Hi, I'm currently trying to work out how to do conditional validation
with nested forms. Googling a bit gave me the following suggestion on
how to disable a nested form:
(From https://cwiki.apache.org/WICKET/conditional-validation.html)
Form nestedForm = new Form("nestedForm") {
@Override
public boolean isEnabled() {
if (getRootForm().findSubmittingButton() != null) {
return getRootForm().findSubmittingButton().getForm() == this;
} else {
return true;
}
}
But when I try this with Wicket 1.4.16 I noticed that
findSubmittingButton internally calls isEnabledInHierarchy which ends up
calling isEnabled so I get stuck in a loop that eventually throws an
exception.
So how should one go about working with nested forms if I don't want the
nested form to be submitted when the outer form is submitted?
Appreciative of any help,
Regards
Robert
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Nested forms and conditional validation
Posted by Igor Vaynberg <ig...@gmail.com>.
depending on external factors while overriding isenabled()/isvisible()
is dangerous for the reasons youve just found out.
this is why we take care to provide alternative hooks, such as
IFormVisitorParticipant
-igor
2011/3/30 Robert Dahlström <ro...@ongame.com>:
> I did manage to get this working using the other pattern from the
> conditional-validation page (i.e. using the FormVisitorParticipant) but I'm
> still curious if the isEnabled solution should work or not?
>
> Regards
> Robert
>
> On 03/30/2011 02:45 PM, Robert Dahlström wrote:
>>
>> Hi, I'm currently trying to work out how to do conditional validation
>> with nested forms. Googling a bit gave me the following suggestion on
>> how to disable a nested form:
>>
>> (From https://cwiki.apache.org/WICKET/conditional-validation.html)
>> Form nestedForm = new Form("nestedForm") {
>> @Override
>> public boolean isEnabled() {
>> if (getRootForm().findSubmittingButton() != null) {
>> return getRootForm().findSubmittingButton().getForm() == this;
>> } else {
>> return true;
>> }
>> }
>>
>> But when I try this with Wicket 1.4.16 I noticed that
>> findSubmittingButton internally calls isEnabledInHierarchy which ends up
>> calling isEnabled so I get stuck in a loop that eventually throws an
>> exception.
>>
>> So how should one go about working with nested forms if I don't want the
>> nested form to be submitted when the outer form is submitted?
>>
>> Appreciative of any help,
>>
>> Regards
>> Robert
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Nested forms and conditional validation
Posted by Robert Dahlström <ro...@ongame.com>.
I did manage to get this working using the other pattern from the
conditional-validation page (i.e. using the FormVisitorParticipant) but
I'm still curious if the isEnabled solution should work or not?
Regards
Robert
On 03/30/2011 02:45 PM, Robert Dahlström wrote:
> Hi, I'm currently trying to work out how to do conditional validation
> with nested forms. Googling a bit gave me the following suggestion on
> how to disable a nested form:
>
> (From https://cwiki.apache.org/WICKET/conditional-validation.html)
> Form nestedForm = new Form("nestedForm") {
> @Override
> public boolean isEnabled() {
> if (getRootForm().findSubmittingButton() != null) {
> return getRootForm().findSubmittingButton().getForm() == this;
> } else {
> return true;
> }
> }
>
> But when I try this with Wicket 1.4.16 I noticed that
> findSubmittingButton internally calls isEnabledInHierarchy which ends up
> calling isEnabled so I get stuck in a loop that eventually throws an
> exception.
>
> So how should one go about working with nested forms if I don't want the
> nested form to be submitted when the outer form is submitted?
>
> Appreciative of any help,
>
> Regards
> Robert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org