Nested forms and conditional validation

2011-03-30 Thread Robert Dahlström
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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Nested forms and conditional validation

2011-03-30 Thread Robert Dahlström
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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Nested forms and conditional validation

2011-03-30 Thread Igor Vaynberg
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 robert.dahlst...@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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org