Alexander -

Usually when I have this situation I just put in an else (or a
logic:notEqual in your case) which prints out the form field as hidden with
some "bogus" data in it. That "bogus" data will be enough to make the
validation pass of course.

I had thought about doing the requiredifpresent or something like that, but
this always seemed much simpler.

Matt Bathje

----- Original Message ----- 
From: "Alexander Craen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, March 02, 2004 8:14 AM
Subject: Re: Struts logic combined with the struts validator


> Maybe i`ll better rephrase my question to make it more easy for the reader
> :)
>
> I want to make a field in a form required when it exists on the form
>
> if it is not on the form (due to some logic tags that make it disappear),
I
> dont want to generate an error.
>
> How would I best solve this?
>
> make a new validator "requiredifpresent" ?
> or could I use the requiredif together with some logic based on values in
> other beans ?
>
>
> ----- Original Message ----- 
> From: "Alexander Craen" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, March 02, 2004 11:25 AM
> Subject: Struts logic combined with the struts validato
>
>
> > Hello,
> > I am making a registration procedure that works with some logic based on
> the
> > choices the customer makes on a previous page
> >
> > <logic:equal name="LogonForm" property="customertype" scope="session"
> > value="business">
> >     <span class="label"><label><bean:message
> > key="text.data.label.bill_vat_number"/></label></span>
> >     <html:text property="bill_vat_nr" styleId="bill_vat_nr" />
> > </logic:equal>
> >
> > Problem description :
> > When a customer is of customertype 'business' the field bill_vat_nr is
> > showed on the page and is required when a customer is not of
customertype
> > 'business' the field bill_vat_nr is not showed on the page and theirfor
is
> > not required
> >
> > I tried to use a standard struts validator implementation
> > <field property="bill_vat_nr" depends="required">
> >     <arg0 key="text.data.label.bill_vat_number"/>
> >     <arg1 key="${dummy}"/>
> > </field>
> >
> > I first thought about using the requiredif implementation. Problem is
that
> I
> > only get it to work with elements from the same form.
> >
> > The result :
> > The bill_vat_nr is required even if it has been left out of the form by
> > struts logic
> >
> > My question :
> > Is their a way to combine struts logic and the validator framework? Do I
> > have to write a custom validator that does some kind of introspection on
> the
> > jsp? Or are their validators that are used for that purpose? What would
be
> > the best solution to tackle this problem?
> >
> > Tnx in advance
> > Alexander Craen
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to