You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by ywtsang <yw...@gmail.com> on 2009/01/03 15:45:40 UTC

Re: Turn off form validation

i also have a similar use case that requires "turning off" validation for
some ajax button links

e.g.
i have a form, that may have some text fields with different/none validators

and i want to do "translation" on some of the text fields by
ajax/dynamically,
so i need to use ajax button links to "submit" the form with the latest
input values to backend logic

for this case, we want to supress the validation error (if any) and have
wicket to still propagate the form fields to our model automatically

we can't use "setdefaultformprocess" to false for the ajax button link

so i go to have a look at the form processing, and copy the wicket's form
property propagation logic to my form's onerror:

<code>
@Override
protected void onError() {
  // just for demonstration, can make it happen only for certain cases only
                
  // before updating, call the interception method for clients
  beforeUpdateFormComponentModels();

  // Update model using form data
  updateFormComponentModels();

  // Persist FormComponents if requested
  // private, can't call
// persistFormComponentData();
               
   super.onError();
}
</code>

there may be problem in propagating the form fields to model if there is
validation error,
but it looks ok to me because the form fields with no validation error
should still get their values submitted and propagated nicely, event some
other form fields may have validation error



noon wrote:
> 
> I solved similar problem where I had some required TextField components
> and an AJAX component which does a AJAX submit. During this AJAX submit I
> wanted to prohibit all the form validations. I achieved this by setting
> the AJAX components (an autocomplete TextField with custom AJAX behaviour)
> into its own nested form... form which is inside another form.
> 
> I'm not sure does this solve your problem. I found my solution just by
> trying differend solutions and it worked :)
> 
> 
> 
> hbf wrote:
>> 
>> I have a custom component that allows the user to select one or more
>> tags. For this, the component has a text field and an AjaxButton "Add"
>> to add a tag.
>> 
>> All works fine if I use the component in a form without validation
>> errors. If, however, a text field has setRequired(true), the
>> AjaxButton's onSubmit() method is not called (but onError() instead).
>> 
>> In this case, I do not want this behaviour but want form validation
>> to be disabled for the "Add" AjaxButton. (I still need to get the
>> model values updated, though.)
>> 
>> Is there an easy way to achieve this?
>> 
>> I've read about conditional validation,
>> 
>>    http://cwiki.apache.org/WICKET/conditional-validation.html
>> 
>> but as my component does not know about the enclosing form, I am
>> looking for another solution.
>> 
>> Many thanks,
>> Kaspar
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Turn-off-form-validation-tp21090395p21265480.html
Sent from the Wicket - User 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: Turn off form validation

Posted by "Hoover, William " <wh...@nemours.org>.
Have you tried processInput? 

-----Original Message-----
From: ywtsang [mailto:ywtsang@gmail.com] 
Sent: Monday, January 05, 2009 10:15 AM
To: users@wicket.apache.org
Subject: RE: Turn off form validation


because this will not update the model object automatically

i.e.
i cannot get the updated submitted fields values


Hoover, William wrote:
> 
> Not sure as to why you cannot use setDefaultFormProcessing?
> 
> http://cwiki.apache.org/WICKET/conditional-validation.html (see 
> "Alternative Approach")
> 
> -----Original Message-----
> From: ywtsang [mailto:ywtsang@gmail.com]
> Sent: Saturday, January 03, 2009 9:46 AM
> To: users@wicket.apache.org
> Subject: Re: Turn off form validation
> 
> 
> i also have a similar use case that requires "turning off" validation 
> for some ajax button links
> 
> e.g.
> i have a form, that may have some text fields with different/none 
> validators
> 
> and i want to do "translation" on some of the text fields by 
> ajax/dynamically, so i need to use ajax button links to "submit" the 
> form with the latest input values to backend logic
> 
> for this case, we want to supress the validation error (if any) and 
> have wicket to still propagate the form fields to our model 
> automatically
> 
> we can't use "setdefaultformprocess" to false for the ajax button link
> 
> so i go to have a look at the form processing, and copy the wicket's 
> form property propagation logic to my form's onerror:
> 
> <code>
> @Override
> protected void onError() {
>   // just for demonstration, can make it happen only for certain cases

> only
>                 
>   // before updating, call the interception method for clients
>   beforeUpdateFormComponentModels();
> 
>   // Update model using form data
>   updateFormComponentModels();
> 
>   // Persist FormComponents if requested
>   // private, can't call
> // persistFormComponentData();
>                
>    super.onError();
> }
> </code>
> 
> there may be problem in propagating the form fields to model if there 
> is validation error, but it looks ok to me because the form fields 
> with no validation error should still get their values submitted and 
> propagated nicely, event some other form fields may have validation 
> error
> 
> 
> 
> noon wrote:
>> 
>> I solved similar problem where I had some required TextField 
>> components and an AJAX component which does a AJAX submit. During 
>> this
> 
>> AJAX submit I wanted to prohibit all the form validations. I achieved

>> this by setting the AJAX components (an autocomplete TextField with 
>> custom AJAX behaviour) into its own nested form... form which is
> inside another form.
>> 
>> I'm not sure does this solve your problem. I found my solution just 
>> by
> 
>> trying differend solutions and it worked :)
>> 
>> 
>> 
>> hbf wrote:
>>> 
>>> I have a custom component that allows the user to select one or more

>>> tags. For this, the component has a text field and an AjaxButton
> "Add"
>>> to add a tag.
>>> 
>>> All works fine if I use the component in a form without validation 
>>> errors. If, however, a text field has setRequired(true), the 
>>> AjaxButton's onSubmit() method is not called (but onError()
instead).
>>> 
>>> In this case, I do not want this behaviour but want form validation 
>>> to be disabled for the "Add" AjaxButton. (I still need to get the 
>>> model values updated, though.)
>>> 
>>> Is there an easy way to achieve this?
>>> 
>>> I've read about conditional validation,
>>> 
>>>    http://cwiki.apache.org/WICKET/conditional-validation.html
>>> 
>>> but as my component does not know about the enclosing form, I am 
>>> looking for another solution.
>>> 
>>> Many thanks,
>>> Kaspar
>>> 
>>> --------------------------------------------------------------------
>>> - To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> 
>>> 
>>> 
>> 
>> 
> 
> --
> View this message in context:
> http://www.nabble.com/Turn-off-form-validation-tp21090395p21265480.htm
> l Sent from the Wicket - User 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
> 
> 
> 

--
View this message in context:
http://www.nabble.com/Turn-off-form-validation-tp21090395p21292775.html
Sent from the Wicket - User 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: Turn off form validation

Posted by ywtsang <yw...@gmail.com>.
because this will not update the model object automatically

i.e.
i cannot get the updated submitted fields values


Hoover, William wrote:
> 
> Not sure as to why you cannot use setDefaultFormProcessing?
> 
> http://cwiki.apache.org/WICKET/conditional-validation.html (see
> "Alternative Approach")
> 
> -----Original Message-----
> From: ywtsang [mailto:ywtsang@gmail.com] 
> Sent: Saturday, January 03, 2009 9:46 AM
> To: users@wicket.apache.org
> Subject: Re: Turn off form validation
> 
> 
> i also have a similar use case that requires "turning off" validation
> for some ajax button links
> 
> e.g.
> i have a form, that may have some text fields with different/none
> validators
> 
> and i want to do "translation" on some of the text fields by
> ajax/dynamically, so i need to use ajax button links to "submit" the
> form with the latest input values to backend logic
> 
> for this case, we want to supress the validation error (if any) and have
> wicket to still propagate the form fields to our model automatically
> 
> we can't use "setdefaultformprocess" to false for the ajax button link
> 
> so i go to have a look at the form processing, and copy the wicket's
> form property propagation logic to my form's onerror:
> 
> <code>
> @Override
> protected void onError() {
>   // just for demonstration, can make it happen only for certain cases
> only
>                 
>   // before updating, call the interception method for clients
>   beforeUpdateFormComponentModels();
> 
>   // Update model using form data
>   updateFormComponentModels();
> 
>   // Persist FormComponents if requested
>   // private, can't call
> // persistFormComponentData();
>                
>    super.onError();
> }
> </code>
> 
> there may be problem in propagating the form fields to model if there is
> validation error, but it looks ok to me because the form fields with no
> validation error should still get their values submitted and propagated
> nicely, event some other form fields may have validation error
> 
> 
> 
> noon wrote:
>> 
>> I solved similar problem where I had some required TextField 
>> components and an AJAX component which does a AJAX submit. During this
> 
>> AJAX submit I wanted to prohibit all the form validations. I achieved 
>> this by setting the AJAX components (an autocomplete TextField with 
>> custom AJAX behaviour) into its own nested form... form which is
> inside another form.
>> 
>> I'm not sure does this solve your problem. I found my solution just by
> 
>> trying differend solutions and it worked :)
>> 
>> 
>> 
>> hbf wrote:
>>> 
>>> I have a custom component that allows the user to select one or more 
>>> tags. For this, the component has a text field and an AjaxButton
> "Add"
>>> to add a tag.
>>> 
>>> All works fine if I use the component in a form without validation 
>>> errors. If, however, a text field has setRequired(true), the 
>>> AjaxButton's onSubmit() method is not called (but onError() instead).
>>> 
>>> In this case, I do not want this behaviour but want form validation 
>>> to be disabled for the "Add" AjaxButton. (I still need to get the 
>>> model values updated, though.)
>>> 
>>> Is there an easy way to achieve this?
>>> 
>>> I've read about conditional validation,
>>> 
>>>    http://cwiki.apache.org/WICKET/conditional-validation.html
>>> 
>>> but as my component does not know about the enclosing form, I am 
>>> looking for another solution.
>>> 
>>> Many thanks,
>>> Kaspar
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> 
>>> 
>>> 
>> 
>> 
> 
> --
> View this message in context:
> http://www.nabble.com/Turn-off-form-validation-tp21090395p21265480.html
> Sent from the Wicket - User 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Turn-off-form-validation-tp21090395p21292775.html
Sent from the Wicket - User 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: Turn off form validation

Posted by "Hoover, William " <wh...@nemours.org>.
Not sure as to why you cannot use setDefaultFormProcessing?

http://cwiki.apache.org/WICKET/conditional-validation.html (see
"Alternative Approach")

-----Original Message-----
From: ywtsang [mailto:ywtsang@gmail.com] 
Sent: Saturday, January 03, 2009 9:46 AM
To: users@wicket.apache.org
Subject: Re: Turn off form validation


i also have a similar use case that requires "turning off" validation
for some ajax button links

e.g.
i have a form, that may have some text fields with different/none
validators

and i want to do "translation" on some of the text fields by
ajax/dynamically, so i need to use ajax button links to "submit" the
form with the latest input values to backend logic

for this case, we want to supress the validation error (if any) and have
wicket to still propagate the form fields to our model automatically

we can't use "setdefaultformprocess" to false for the ajax button link

so i go to have a look at the form processing, and copy the wicket's
form property propagation logic to my form's onerror:

<code>
@Override
protected void onError() {
  // just for demonstration, can make it happen only for certain cases
only
                
  // before updating, call the interception method for clients
  beforeUpdateFormComponentModels();

  // Update model using form data
  updateFormComponentModels();

  // Persist FormComponents if requested
  // private, can't call
// persistFormComponentData();
               
   super.onError();
}
</code>

there may be problem in propagating the form fields to model if there is
validation error, but it looks ok to me because the form fields with no
validation error should still get their values submitted and propagated
nicely, event some other form fields may have validation error



noon wrote:
> 
> I solved similar problem where I had some required TextField 
> components and an AJAX component which does a AJAX submit. During this

> AJAX submit I wanted to prohibit all the form validations. I achieved 
> this by setting the AJAX components (an autocomplete TextField with 
> custom AJAX behaviour) into its own nested form... form which is
inside another form.
> 
> I'm not sure does this solve your problem. I found my solution just by

> trying differend solutions and it worked :)
> 
> 
> 
> hbf wrote:
>> 
>> I have a custom component that allows the user to select one or more 
>> tags. For this, the component has a text field and an AjaxButton
"Add"
>> to add a tag.
>> 
>> All works fine if I use the component in a form without validation 
>> errors. If, however, a text field has setRequired(true), the 
>> AjaxButton's onSubmit() method is not called (but onError() instead).
>> 
>> In this case, I do not want this behaviour but want form validation 
>> to be disabled for the "Add" AjaxButton. (I still need to get the 
>> model values updated, though.)
>> 
>> Is there an easy way to achieve this?
>> 
>> I've read about conditional validation,
>> 
>>    http://cwiki.apache.org/WICKET/conditional-validation.html
>> 
>> but as my component does not know about the enclosing form, I am 
>> looking for another solution.
>> 
>> Many thanks,
>> Kaspar
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
>> 
>> 
> 
> 

--
View this message in context:
http://www.nabble.com/Turn-off-form-validation-tp21090395p21265480.html
Sent from the Wicket - User 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