You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by rawe <ra...@dachser.com> on 2011/10/17 17:11:22 UTC

Validating in form returns always error but textfield has a value

I'm using a LinkTree and to each node a panel is referenced.
Both is embedded in a form component.
The panels have textfields.
When using a submit button or a SubmitLink the input of the
textfields is valid and then also validation is valid.

But:
My intension is also to validate the form each time the node is changed. So
I'm using
the method form.validate() directly.
But the textfields have all null input!
--> validation error also when there is a value inside textfield.

Why the (raw)input is not recognized  (the textfield model is ok) ?
what I'm doing wrong. How can I solve this problem?

thank you for hints!

Ralph

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Validating-in-form-returns-always-error-but-textfield-has-a-value-tp3912361p3912361.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: Validating in form returns always error but textfield has a value

Posted by rawe <ra...@dachser.com>.
Got it !
Thank you!

Ralph

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Validating-in-form-returns-always-error-but-textfield-has-a-value-tp3912361p3914841.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: Validating in form returns always error but textfield has a value

Posted by manuelbarzi <ma...@gmail.com>.
> See also Wicket API Doc of Form: (
> http://wicket.apache.org/apidocs/1.4/org/apache/wicket/markup/html/form/Form.html
> Wicket API Doc )
> "/If you want you can call validate() to execute form validation, hasError()
> to find out whether validate() resulted in validation errors, and
> updateFormComponentModels() to update the models of nested form
> components./"

> the first two are working perfect, but not the programmatic way.

this already well-known form procedure would work if you were
submitting the form with a component implementing the
IFormSubmittingComponent interface.

> Nevertheless I found a solution for my problem. I'm using a SubmitLink in my
> LinkTree component.
> For that I had to override the newLink() method of LinkTree.

by default BaseTree.newLink is providing Link or AjaxLink, which
doesn't implement IFormSubmittingComponent, required for a component
that is able to submit a form. so, as guessed before, you were not
submitting the form each time you were clicking on each tree node.
now, using SubmitLink, it works, as it implements the mentioned
interface. got it?

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


Re: Validating in form returns always error but textfield has a value

Posted by rawe <ra...@dachser.com>.
Yes, I'm using the form default setting (DefaultFormProcessing = true).
But for form processing you have to use a submit button or a SubmitLink or
you can call the form validate() method programmatic.

See also Wicket API Doc of Form: (
http://wicket.apache.org/apidocs/1.4/org/apache/wicket/markup/html/form/Form.html
Wicket API Doc )
"/If you want you can call validate() to execute form validation, hasError()
to find out whether validate() resulted in validation errors, and
updateFormComponentModels() to update the models of nested form
components./"

the first two are working perfect, but not the programmatic way.
Nevertheless I found a solution for my problem. I'm using a SubmitLink in my
LinkTree component.
For that I had to override the newLink() method of LinkTree.


see also the thread: 
http://apache-wicket.1842946.n4.nabble.com/Using-SubmitLink-as-a-tree-node-tc3914407.html
SubmitLink in BaseTree 

Thanks for your hints!

Ralph

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Validating-in-form-returns-always-error-but-textfield-has-a-value-tp3912361p3914717.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: Validating in form returns always error but textfield has a value

Posted by manuelbarzi <ma...@gmail.com>.
at which point are you pretending to call validate, what logic fires
it? see no code

if defaultFormProcessing is true (default) on submitting components,
then all validation and form updating is executed automatically.


On Tue, Oct 18, 2011 at 8:52 AM, rawe <ra...@dachser.com> wrote:
> Here are some code snippets.
>
> When clicking on a tree node I validate the form..
> If no errors I update the form component models.
> The class MyMutableTreeNode extends DefaultMutableTreeNode.
> Each node references an own panel component.
> getNodeEntryDetail() returns the panel referenced by the node.
>
> Where is the difference to a SubmitLink call. If calling SubmitLink
> validation works fine and input values of the textfields in panel are
> filled.
> When calling validate() programmatic the input values are null.
>
> ??
>
>
>
> ralph
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Validating-in-form-returns-always-error-but-textfield-has-a-value-tp3912361p3914396.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: Validating in form returns always error but textfield has a value

Posted by rawe <ra...@dachser.com>.
Here are some code snippets.

When clicking on a tree node I validate the form..
If no errors I update the form component models.
The class MyMutableTreeNode extends DefaultMutableTreeNode.
Each node references an own panel component.
getNodeEntryDetail() returns the panel referenced by the node.

Where is the difference to a SubmitLink call. If calling SubmitLink
validation works fine and input values of the textfields in panel are
filled.
When calling validate() programmatic the input values are null.

??



ralph

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Validating-in-form-returns-always-error-but-textfield-has-a-value-tp3912361p3914396.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: Validating in form returns always error but textfield has a value

Posted by manuelbarzi <ma...@gmail.com>.
may you provide a code shot for review?

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


Re: Validating in form returns always error but textfield has a value

Posted by rawe <ra...@dachser.com>.
Yes, each time I  change the node the form is submitted.
The textfields in the panel are initialized via PropertyModel and are set to
required.
When I want to change the node I call validate() but the rawInput of
textfields is null.
--> form.hasError() is always true, but there are values in the textfields.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Validating-in-form-returns-always-error-but-textfield-has-a-value-tp3912361p3912457.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: Validating in form returns always error but textfield has a value

Posted by manuelbarzi <ma...@gmail.com>.
is the form submitted each time a node is changed? if not, then it
could be normal you read nulls, as the values are still on browser,
but havent flown to server.


On Mon, Oct 17, 2011 at 5:11 PM, rawe <ra...@dachser.com> wrote:
> I'm using a LinkTree and to each node a panel is referenced.
> Both is embedded in a form component.
> The panels have textfields.
> When using a submit button or a SubmitLink the input of the
> textfields is valid and then also validation is valid.
>
> But:
> My intension is also to validate the form each time the node is changed. So
> I'm using
> the method form.validate() directly.
> But the textfields have all null input!
> --> validation error also when there is a value inside textfield.
>
> Why the (raw)input is not recognized  (the textfield model is ok) ?
> what I'm doing wrong. How can I solve this problem?
>
> thank you for hints!
>
> Ralph
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Validating-in-form-returns-always-error-but-textfield-has-a-value-tp3912361p3912361.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