You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Brown, Berlin [GCG-PFS]" <Be...@Primerica.com> on 2011/03/05 00:32:17 UTC

Good way to remove validation globally from a page or panel

If I am using AbstractFormValidator and in some places, I am using
setRequired, default validation on components.  What is the best way to
remove the validation "temporarily"  Let's say I am in a view only mode
and fields are disabled, I want to remove validation.  And then later
on, may add back that validation.  I guess I Could remove and add
onBeforeRender or initialize or configure and then add the validators
back.  I was trying to avoid doin that.   I would have to remove
validation on all the components on those particular pages.  Also, I was
thinking of just exiting early in the validation methods?  
 
Also, let's say I have some fields that are disabled and some that
aren't.  I am using abstractformvalidator and throwing an error if those
fields are empty.  They are empty but disabled.  Is there a way to treat
disabled fields differently in validation modes..

RE: Good way to remove validation globally from a page or panel

Posted by "Brown, Berlin [GCG-PFS]" <Be...@Primerica.com>.
I should have clarified.

Yea, if you have input fields with a dozen or so fields and you have 50%
disabled.  But you are using the AbstractFormValidator validate() {
get("field1").getInput; get("field2").getInput ... And doing validation
checks, I guess this isn't a good approach.

I have to keep the fields disabled and can't use true/read only spans.

I could visit each field and check if the component is enabled or not,
but I was trying to see if there is a one liner, easy solution that I
could remove validation in a disabled state...if I use the validation
approach I mention above.

-----Original Message-----
From: Martin Grigorov [mailto:mgrigorov@apache.org] 
Sent: Saturday, March 05, 2011 3:59 AM
To: users@wicket.apache.org
Subject: Re: Good way to remove validation globally from a page or panel

When you are in View mode then either your components are not form
components (e.g. <input> is replaced with <label>/<span>/...) or as you
said they are disabled. Form submit will not send name/value pair for
disabled form elements.

I think the first approach is better regarding user experience.
See visural's "view or edit" components for example.

On Sat, Mar 5, 2011 at 1:32 AM, Brown, Berlin [GCG-PFS] <
Berlin.Brown@primerica.com> wrote:

> If I am using AbstractFormValidator and in some places, I am using 
> setRequired, default validation on components.  What is the best way 
> to remove the validation "temporarily"  Let's say I am in a view only 
> mode and fields are disabled, I want to remove validation.  And then 
> later on, may add back that validation.  I guess I Could remove and 
> add onBeforeRender or initialize or configure and then add the
validators
> back.  I was trying to avoid doin that.   I would have to remove
> validation on all the components on those particular pages.  Also, I 
> was thinking of just exiting early in the validation methods?
>
> Also, let's say I have some fields that are disabled and some that 
> aren't.  I am using abstractformvalidator and throwing an error if 
> those fields are empty.  They are empty but disabled.  Is there a way 
> to treat disabled fields differently in validation modes..
>


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


Re: Good way to remove validation globally from a page or panel

Posted by Martin Grigorov <mg...@apache.org>.
When you are in View mode then either your components are not form
components (e.g. <input> is replaced with <label>/<span>/...) or as you said
they are disabled. Form submit will not send name/value pair for disabled
form elements.

I think the first approach is better regarding user experience.
See visural's "view or edit" components for example.

On Sat, Mar 5, 2011 at 1:32 AM, Brown, Berlin [GCG-PFS] <
Berlin.Brown@primerica.com> wrote:

> If I am using AbstractFormValidator and in some places, I am using
> setRequired, default validation on components.  What is the best way to
> remove the validation "temporarily"  Let's say I am in a view only mode
> and fields are disabled, I want to remove validation.  And then later
> on, may add back that validation.  I guess I Could remove and add
> onBeforeRender or initialize or configure and then add the validators
> back.  I was trying to avoid doin that.   I would have to remove
> validation on all the components on those particular pages.  Also, I was
> thinking of just exiting early in the validation methods?
>
> Also, let's say I have some fields that are disabled and some that
> aren't.  I am using abstractformvalidator and throwing an error if those
> fields are empty.  They are empty but disabled.  Is there a way to treat
> disabled fields differently in validation modes..
>