You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by eugenebalt <eu...@yahoo.com> on 2013/08/14 20:20:25 UTC

Forcing Form Validation from another Form's onValidate()

I have a Panel (P1) which contains its own form (P1_F1).

The P1 panel also contains another panel inside itself, P1_A, which has its
own inner form (let's call it P1_A_F1).

Whenever the P_F1's validation is called, I also have to call the P1_A_F1
form validation. It doesn't get called automatically. How can I achieve
that?

In the P1_F1, I am catching onValidate() and overriding it. The problem is,
to call the validate() method, I need a FormComponent, not a Form. So I can
find the right form to additionally validate, but the method is not
available without a FormComponent. Any ideas? Thanks


P1_F1's onValidate captured:

@Override
protected void onValidate() {
  Panel P1_A = (Panel)get("P1_A");
  Form P1_A_F1 = (Form)P1_A.get("P1_A_F1");
  // how to force validation now on P1_A_F1?
}



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Forcing-Form-Validation-from-another-Form-s-onValidate-tp4660895.html
Sent from the Users forum mailing list archive at Nabble.com.

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


RE: Forcing Form Validation from another Form's onValidate()

Posted by eugenebalt <eu...@yahoo.com>.
Actually, I figured it out. All the validators are getting called from the
inner form. But there was an NullPointerException in the first validator
which blocked all the others and I wasn't seeing them. Thanks for your help.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Forcing-Form-Validation-from-another-Form-s-onValidate-tp4660895p4660918.html
Sent from the Users forum mailing list archive at Nabble.com.

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


RE: Forcing Form Validation from another Form's onValidate()

Posted by eugenebalt <eu...@yahoo.com>.
Looking further at my code, I see that the custom validators from the inner
form DO get called; but the one that doesn't get called is
.setRequired(true). There is one component in the inner form which is
setRequired(true). And that validation is bypassed for some reason, although
all the other ones are not. Any thoughts on this?

Thanks for your replies.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Forcing-Form-Validation-from-another-Form-s-onValidate-tp4660895p4660917.html
Sent from the Users forum mailing list archive at Nabble.com.

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


RE: Forcing Form Validation from another Form's onValidate()

Posted by Paul Bors <pa...@bors.ws>.
In the final HTML, my form is flattened out, there is only <Form>.

That's because Wicket supports nested forms but HTML does not.
Wicket will hide any inner <form> tags but keep the Form object references.
See section 10.5 Nested Forms of the Wicket Free Guide for more details.
http://wicket.apache.org/learn/books/freeguide.html


In my Wicket markup, the structure is:
PANEL -> FORM -> SecondPanel -> SecondForm

The main PANEL's FORM is being submitted, and validated. But the
"SecondForm" validation never gets called.

So you want to validate the inner nested form when submitting the outer
parent form. I take it that's the first use-case described at:
https://cwiki.apache.org/confluence/display/WICKET/Nested+Forms

all forms enabled
outer form submitted

Outer Middle Inner 
*S*   S      S

Looking over the Form's validateComponents() method it does a post order
traversal of all form components.

I would say, create a quick-start so we better understand how your code is
configured because as far as I recall this is the default behavior. Perhaps
I'm wrong, but at least a quick-start would aid in helping you without
guessing.

To create a quick start see:
http://wicket.apache.org/start/quickstart.html

~ Thank you,
  Paul Bors

--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Forcing-Form-Validation-from-anot
her-Form-s-onValidate-tp4660895p4660905.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
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: Forcing Form Validation from another Form's onValidate()

Posted by eugenebalt <eu...@yahoo.com>.
In the final HTML, my form is flattened out, there is only <Form>.

In my Wicket markup, the structure is:
PANEL -> FORM -> SecondPanel -> SecondForm

The main PANEL's FORM is being submitted, and validated. But the
"SecondForm" validation never gets called.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Forcing-Form-Validation-from-another-Form-s-onValidate-tp4660895p4660905.html
Sent from the Users forum mailing list archive at Nabble.com.

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


RE: Forcing Form Validation from another Form's onValidate()

Posted by Paul Bors <pa...@bors.ws>.
Have you checked the Wiki pages?
https://cwiki.apache.org/confluence/display/WICKET/Nested+Forms

Which use-case are your referring to again?

~ Thank you,
  Paul Bors

-----Original Message-----
From: eugenebalt [mailto:eugenebalt@yahoo.com] 
Sent: Wednesday, August 14, 2013 2:20 PM
To: users@wicket.apache.org
Subject: Forcing Form Validation from another Form's onValidate()

I have a Panel (P1) which contains its own form (P1_F1).

The P1 panel also contains another panel inside itself, P1_A, which has its
own inner form (let's call it P1_A_F1).

Whenever the P_F1's validation is called, I also have to call the P1_A_F1
form validation. It doesn't get called automatically. How can I achieve
that?

In the P1_F1, I am catching onValidate() and overriding it. The problem is,
to call the validate() method, I need a FormComponent, not a Form. So I can
find the right form to additionally validate, but the method is not
available without a FormComponent. Any ideas? Thanks


P1_F1's onValidate captured:

@Override
protected void onValidate() {
  Panel P1_A = (Panel)get("P1_A");
  Form P1_A_F1 = (Form)P1_A.get("P1_A_F1");
  // how to force validation now on P1_A_F1?
}



--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Forcing-Form-Validation-from-anot
her-Form-s-onValidate-tp4660895.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
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