Quantcast

AjaxFormComponentUpdatingBehavior, required fields and validation

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

AjaxFormComponentUpdatingBehavior, required fields and validation

Michal Wegrzyn
Hi,

I have form with few TextField and DropDownChoice components. All of them have added AjaxFormComponentUpdatingBehavior( "onkeyup" ) and are set as required. Some of them are wrapped in my custom objects, but it does not matter (validation and processing logic is in behavior).

With this setup after every ajax update triggered with behaviour's onUpdate( AjaxRequestTarget ) or onError( AjaxRequestTarget ) I try to check if form components are valid and give instant feedback to user.

Unfortunately results obtained from component's isValid() are wrong. Empty TextFields are almost always valid.
Only after clearing TextField error is added to component, but after changing for example other TextField to whatever value (and thus triggering next validation check) isValid() on blank, required TextField returns true.

Is this approach incorrect or am I missing something?

Best regards,
Michal Wegrzyn


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: AjaxFormComponentUpdatingBehavior, required fields and validation

Michal Wegrzyn
Any ideas here? Should I provide a quickstart?

Best regards,
Michal Wegrzyn

> -----Original Message-----
> From: Michal Wegrzyn [mailto:[hidden email]]
> Sent: Monday, December 19, 2011 23:07
> To: [hidden email]
> Subject: AjaxFormComponentUpdatingBehavior, required fields and
> validation
>
> Hi,
>
> I have form with few TextField and DropDownChoice components. All of
> them have added AjaxFormComponentUpdatingBehavior( "onkeyup" ) and are
> set as required. Some of them are wrapped in my custom objects, but it
> does not matter (validation and processing logic is in behavior).
>
> With this setup after every ajax update triggered with behaviour's
> onUpdate( AjaxRequestTarget ) or onError( AjaxRequestTarget ) I try to
> check if form components are valid and give instant feedback to user.
>
> Unfortunately results obtained from component's isValid() are wrong.
> Empty TextFields are almost always valid.
> Only after clearing TextField error is added to component, but after
> changing for example other TextField to whatever value (and thus
> triggering next validation check) isValid() on blank, required
> TextField returns true.
>
> Is this approach incorrect or am I missing something?
>
> Best regards,
> Michal Wegrzyn
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: AjaxFormComponentUpdatingBehavior, required fields and validation

Sven Meier
Hi,

are you validating all form components or just the one which triggered
the ajax request?

You know AjaxFormSubmitBehavior?

Sven

Am 03.01.2012 09:32, schrieb Michal Wegrzyn:

> Any ideas here? Should I provide a quickstart?
>
> Best regards,
> Michal Wegrzyn
>
>> -----Original Message-----
>> From: Michal Wegrzyn [mailto:[hidden email]]
>> Sent: Monday, December 19, 2011 23:07
>> To: [hidden email]
>> Subject: AjaxFormComponentUpdatingBehavior, required fields and
>> validation
>>
>> Hi,
>>
>> I have form with few TextField and DropDownChoice components. All of
>> them have added AjaxFormComponentUpdatingBehavior( "onkeyup" ) and are
>> set as required. Some of them are wrapped in my custom objects, but it
>> does not matter (validation and processing logic is in behavior).
>>
>> With this setup after every ajax update triggered with behaviour's
>> onUpdate( AjaxRequestTarget ) or onError( AjaxRequestTarget ) I try to
>> check if form components are valid and give instant feedback to user.
>>
>> Unfortunately results obtained from component's isValid() are wrong.
>> Empty TextFields are almost always valid.
>> Only after clearing TextField error is added to component, but after
>> changing for example other TextField to whatever value (and thus
>> triggering next validation check) isValid() on blank, required
>> TextField returns true.
>>
>> Is this approach incorrect or am I missing something?
>>
>> Best regards,
>> Michal Wegrzyn
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: AjaxFormComponentUpdatingBehavior, required fields and validation

Martin Grigorov-4
Additionally "keyup" for <select> is not the best event.
People prefer using the mouse to change the value.

On Tue, Jan 3, 2012 at 11:13 AM, Sven Meier <[hidden email]> wrote:

> Hi,
>
> are you validating all form components or just the one which triggered the
> ajax request?
>
> You know AjaxFormSubmitBehavior?
>
> Sven
>
> Am 03.01.2012 09:32, schrieb Michal Wegrzyn:
>
>> Any ideas here? Should I provide a quickstart?
>>
>> Best regards,
>> Michal Wegrzyn
>>
>>> -----Original Message-----
>>> From: Michal Wegrzyn [mailto:[hidden email]]
>>> Sent: Monday, December 19, 2011 23:07
>>> To: [hidden email]
>>> Subject: AjaxFormComponentUpdatingBehavior, required fields and
>>> validation
>>>
>>> Hi,
>>>
>>> I have form with few TextField and DropDownChoice components. All of
>>> them have added AjaxFormComponentUpdatingBehavior( "onkeyup" ) and are
>>> set as required. Some of them are wrapped in my custom objects, but it
>>> does not matter (validation and processing logic is in behavior).
>>>
>>> With this setup after every ajax update triggered with behaviour's
>>> onUpdate( AjaxRequestTarget ) or onError( AjaxRequestTarget ) I try to
>>> check if form components are valid and give instant feedback to user.
>>>
>>> Unfortunately results obtained from component's isValid() are wrong.
>>> Empty TextFields are almost always valid.
>>> Only after clearing TextField error is added to component, but after
>>> changing for example other TextField to whatever value (and thus
>>> triggering next validation check) isValid() on blank, required
>>> TextField returns true.
>>>
>>> Is this approach incorrect or am I missing something?
>>>
>>> Best regards,
>>> Michal Wegrzyn
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: AjaxFormComponentUpdatingBehavior, required fields and validation

Michal Wegrzyn
In reply to this post by Sven Meier
Hi Sven,

When event is triggered I check all components with #isValid().
I am not sure if validation is performed after every ajax update or only after submit?

I am aware of AjaxFormSubmitBehavior, but I want to check fields after every user action, so user can know error immediately and not only after submit.

Best regards,
Michal

> -----Original Message-----
> From: Sven Meier [mailto:[hidden email]]
> Sent: Tuesday, January 03, 2012 10:13
> To: [hidden email]
> Subject: Re: AjaxFormComponentUpdatingBehavior, required fields and
> validation
>
> Hi,
>
> are you validating all form components or just the one which triggered
> the ajax request?
>
> You know AjaxFormSubmitBehavior?
>
> Sven
>
> Am 03.01.2012 09:32, schrieb Michal Wegrzyn:
> > Any ideas here? Should I provide a quickstart?
> >
> > Best regards,
> > Michal Wegrzyn
> >
> >> -----Original Message-----
> >> From: Michal Wegrzyn [mailto:[hidden email]]
> >> Sent: Monday, December 19, 2011 23:07
> >> To: [hidden email]
> >> Subject: AjaxFormComponentUpdatingBehavior, required fields and
> >> validation
> >>
> >> Hi,
> >>
> >> I have form with few TextField and DropDownChoice components. All of
> >> them have added AjaxFormComponentUpdatingBehavior( "onkeyup" ) and
> are
> >> set as required. Some of them are wrapped in my custom objects, but
> it
> >> does not matter (validation and processing logic is in behavior).
> >>
> >> With this setup after every ajax update triggered with behaviour's
> >> onUpdate( AjaxRequestTarget ) or onError( AjaxRequestTarget ) I try
> to
> >> check if form components are valid and give instant feedback to
> user.
> >>
> >> Unfortunately results obtained from component's isValid() are wrong.
> >> Empty TextFields are almost always valid.
> >> Only after clearing TextField error is added to component, but after
> >> changing for example other TextField to whatever value (and thus
> >> triggering next validation check) isValid() on blank, required
> >> TextField returns true.
> >>
> >> Is this approach incorrect or am I missing something?
> >>
> >> Best regards,
> >> Michal Wegrzyn
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: AjaxFormComponentUpdatingBehavior, required fields and validation

Sven Meier
AjaxFormComponentUpdatingBehavior processes a single component only (change input, validate, convert), so it doesn't make sense to validate all components.
In that case you should use AjaxFormSubmitBehavior, which processes the whole form.

Sven


Am 03.01.2012 10:26, schrieb Michal Wegrzyn:

> Hi Sven,
>
> When event is triggered I check all components with #isValid().
> I am not sure if validation is performed after every ajax update or only after submit?
>
> I am aware of AjaxFormSubmitBehavior, but I want to check fields after every user action, so user can know error immediately and not only after submit.
>
> Best regards,
> Michal
>
>> -----Original Message-----
>> From: Sven Meier [mailto:[hidden email]]
>> Sent: Tuesday, January 03, 2012 10:13
>> To: [hidden email]
>> Subject: Re: AjaxFormComponentUpdatingBehavior, required fields and
>> validation
>>
>> Hi,
>>
>> are you validating all form components or just the one which triggered
>> the ajax request?
>>
>> You know AjaxFormSubmitBehavior?
>>
>> Sven
>>
>> Am 03.01.2012 09:32, schrieb Michal Wegrzyn:
>>> Any ideas here? Should I provide a quickstart?
>>>
>>> Best regards,
>>> Michal Wegrzyn
>>>
>>>> -----Original Message-----
>>>> From: Michal Wegrzyn [mailto:[hidden email]]
>>>> Sent: Monday, December 19, 2011 23:07
>>>> To: [hidden email]
>>>> Subject: AjaxFormComponentUpdatingBehavior, required fields and
>>>> validation
>>>>
>>>> Hi,
>>>>
>>>> I have form with few TextField and DropDownChoice components. All of
>>>> them have added AjaxFormComponentUpdatingBehavior( "onkeyup" ) and
>> are
>>>> set as required. Some of them are wrapped in my custom objects, but
>> it
>>>> does not matter (validation and processing logic is in behavior).
>>>>
>>>> With this setup after every ajax update triggered with behaviour's
>>>> onUpdate( AjaxRequestTarget ) or onError( AjaxRequestTarget ) I try
>> to
>>>> check if form components are valid and give instant feedback to
>> user.
>>>> Unfortunately results obtained from component's isValid() are wrong.
>>>> Empty TextFields are almost always valid.
>>>> Only after clearing TextField error is added to component, but after
>>>> changing for example other TextField to whatever value (and thus
>>>> triggering next validation check) isValid() on blank, required
>>>> TextField returns true.
>>>>
>>>> Is this approach incorrect or am I missing something?
>>>>
>>>> Best regards,
>>>> Michal Wegrzyn
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: AjaxFormComponentUpdatingBehavior, required fields and validation

Michal Wegrzyn
In reply to this post by Martin Grigorov-4
<select> elements have "onchange" of course.
Forgot over them at that point ("ontired" occurred).

Best regards,
Michal Wegrzyn

> -----Original Message-----
> From: Martin Grigorov [mailto:[hidden email]]
> Sent: Tuesday, January 03, 2012 10:20
> To: [hidden email]
> Subject: Re: AjaxFormComponentUpdatingBehavior, required fields and
> validation
>
> Additionally "keyup" for <select> is not the best event.
> People prefer using the mouse to change the value.
>
> On Tue, Jan 3, 2012 at 11:13 AM, Sven Meier <[hidden email]> wrote:
> > Hi,
> >
> > are you validating all form components or just the one which
> triggered the
> > ajax request?
> >
> > You know AjaxFormSubmitBehavior?
> >
> > Sven
> >
> > Am 03.01.2012 09:32, schrieb Michal Wegrzyn:
> >
> >> Any ideas here? Should I provide a quickstart?
> >>
> >> Best regards,
> >> Michal Wegrzyn
> >>
> >>> -----Original Message-----
> >>> From: Michal Wegrzyn [mailto:[hidden email]]
> >>> Sent: Monday, December 19, 2011 23:07
> >>> To: [hidden email]
> >>> Subject: AjaxFormComponentUpdatingBehavior, required fields and
> >>> validation
> >>>
> >>> Hi,
> >>>
> >>> I have form with few TextField and DropDownChoice components. All
> of
> >>> them have added AjaxFormComponentUpdatingBehavior( "onkeyup" ) and
> are
> >>> set as required. Some of them are wrapped in my custom objects, but
> it
> >>> does not matter (validation and processing logic is in behavior).
> >>>
> >>> With this setup after every ajax update triggered with behaviour's
> >>> onUpdate( AjaxRequestTarget ) or onError( AjaxRequestTarget ) I try
> to
> >>> check if form components are valid and give instant feedback to
> user.
> >>>
> >>> Unfortunately results obtained from component's isValid() are
> wrong.
> >>> Empty TextFields are almost always valid.
> >>> Only after clearing TextField error is added to component, but
> after
> >>> changing for example other TextField to whatever value (and thus
> >>> triggering next validation check) isValid() on blank, required
> >>> TextField returns true.
> >>>
> >>> Is this approach incorrect or am I missing something?
> >>>
> >>> Best regards,
> >>> Michal Wegrzyn
> >>>
> >>
> >> --------------------------------------------------------------------
> -
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: AjaxFormComponentUpdatingBehavior, required fields and validation

Michal Wegrzyn
In reply to this post by Sven Meier
Right, using AjaxFormSubmitBehavior (extending AjaxFormValidatingBehavior precisely) and removing all AjaxFormComponentUpdatingBehaviors  did the trick in this case.

After checking JavaDoc I thought that AjaxFormSubmitBehavior can be used only at exact submit phase, but after checking code everything was clear.

Thanks for your help.

Michal

> -----Original Message-----
> From: Sven Meier [mailto:[hidden email]]
> Sent: Tuesday, January 03, 2012 11:45
> To: [hidden email]
> Subject: Re: AjaxFormComponentUpdatingBehavior, required fields and
> validation
>
> AjaxFormComponentUpdatingBehavior processes a single component only
> (change input, validate, convert), so it doesn't make sense to validate
> all components.
> In that case you should use AjaxFormSubmitBehavior, which processes the
> whole form.
>
> Sven
>
>
> Am 03.01.2012 10:26, schrieb Michal Wegrzyn:
> > Hi Sven,
> >
> > When event is triggered I check all components with #isValid().
> > I am not sure if validation is performed after every ajax update or
> only after submit?
> >
> > I am aware of AjaxFormSubmitBehavior, but I want to check fields
> after every user action, so user can know error immediately and not
> only after submit.
> >
> > Best regards,
> > Michal
> >
> >> -----Original Message-----
> >> From: Sven Meier [mailto:[hidden email]]
> >> Sent: Tuesday, January 03, 2012 10:13
> >> To: [hidden email]
> >> Subject: Re: AjaxFormComponentUpdatingBehavior, required fields and
> >> validation
> >>
> >> Hi,
> >>
> >> are you validating all form components or just the one which
> triggered
> >> the ajax request?
> >>
> >> You know AjaxFormSubmitBehavior?
> >>
> >> Sven
> >>
> >> Am 03.01.2012 09:32, schrieb Michal Wegrzyn:
> >>> Any ideas here? Should I provide a quickstart?
> >>>
> >>> Best regards,
> >>> Michal Wegrzyn
> >>>
> >>>> -----Original Message-----
> >>>> From: Michal Wegrzyn [mailto:[hidden email]]
> >>>> Sent: Monday, December 19, 2011 23:07
> >>>> To: [hidden email]
> >>>> Subject: AjaxFormComponentUpdatingBehavior, required fields and
> >>>> validation
> >>>>
> >>>> Hi,
> >>>>
> >>>> I have form with few TextField and DropDownChoice components. All
> of
> >>>> them have added AjaxFormComponentUpdatingBehavior( "onkeyup" ) and
> >> are
> >>>> set as required. Some of them are wrapped in my custom objects,
> but
> >> it
> >>>> does not matter (validation and processing logic is in behavior).
> >>>>
> >>>> With this setup after every ajax update triggered with behaviour's
> >>>> onUpdate( AjaxRequestTarget ) or onError( AjaxRequestTarget ) I
> try
> >> to
> >>>> check if form components are valid and give instant feedback to
> >> user.
> >>>> Unfortunately results obtained from component's isValid() are
> wrong.
> >>>> Empty TextFields are almost always valid.
> >>>> Only after clearing TextField error is added to component, but
> after
> >>>> changing for example other TextField to whatever value (and thus
> >>>> triggering next validation check) isValid() on blank, required
> >>>> TextField returns true.
> >>>>
> >>>> Is this approach incorrect or am I missing something?
> >>>>
> >>>> Best regards,
> >>>> Michal Wegrzyn
> >>>>
> >>> -------------------------------------------------------------------
> --
> >>> To unsubscribe, e-mail: [hidden email]
> >>> For additional commands, e-mail: [hidden email]
> >>>
> >>
> >> --------------------------------------------------------------------
> -
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...