You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chetan Pandey <cp...@BLUEsingapore.com> on 2006/08/01 06:24:53 UTC

Struts ComboBox Validation

I have the following Combobox in my Struts Application:

 

 

<td><bean:message key="attendee.holidexCode"/>*</td>

<td>

<html:select property="attendeeVO.holidexCode" >

<html:option value="Choose Holidex"> </html:option> 

<html:options name="holidexCodeVector" /> 

</html:select>

</td>

 

Where holidexCodeVector is a simple Vector of Strings where currently only
three values are stored: 

"IND"

"AUS"
"USA"

 

I want to validate holidexCode using validation.xml

<field

                property="attendeeVO.holidexCode"

                depends="required">

                    <arg0 key="attendee.holidexCode"/>

</field>

 

But the thing is, since the default value is "Choose Holidex" it considers
it a String and doesn't validate.

 

So I end up getting "Choose Holidex" as a possible Value.

 

I want to stop this. I want control to proceed only when they have choses
"IND", "AUS" or "USA" only.

 

Thanks.

 

 

Chetan


Re: Struts ComboBox Validation

Posted by Irwan Nurwandi <ir...@gmail.com>.
Hello Chetan

It's seem nothing wrong with your code and configuration xml.
Are you sure this malicious things happens from this code section.

Try to specify more precisely the message key in your Message
Resources property file.
Maybe the message error come from the other section of code ..

Sorry if I couldn't help ..

Regards
IN

On 8/1/06, Chetan Pandey <cp...@bluesingapore.com> wrote:
> Hi Irwan:
>
> Thanks for the reply.
>
> It did solve my problem but not for the Combo-box which takes ints.
>
> Consider the following:
>
> <td>
> <html:select property="attendeeVO.role" >
> <html:option value="">Choose Role</html:option>
> <html:options collection="roleVector" labelProperty="description"
> property="roleId"/>
> </html:select>
> </td>
>
>
> In which we have to set the property called attendeeVO.role which is an int.
>
> Its initial values come from roleVector which holds a String and int pair of
> values.
>
> The String is displayed but only the int is returned.
>
> I am Trying the following in my validation.xml :
>              <field
>                 property="attendeeVO.role"
>                 depends="required">
>                     <arg0 key="attendee.role"/>
>             </field>
> However, even if a value other than "Choose Role" such as Hotel GM,  Hotel
> Staff is chose I still get a Validation error message that Role is not
> available.
>
> Thanks.
>
> Chetan Pandey
>
>
> -----Original Message-----
> From: Irwan Nurwandi [mailto:irwan.nurwandi@gmail.com]
> Sent: Tuesday, August 01, 2006 1:11 PM
> To: Struts Users Mailing List
> Subject: Re: Struts ComboBox Validation
>
> >
> > But the thing is, since the default value is "Choose Holidex" it considers
> > it a String and doesn't validate.
>
> it's should be
> <html:option value="">Choose Holidex</html:option>
>
> not this one ...
> <html:option value="Choose Holidex"> </html:option>
>
> Regards
> IN
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Struts ComboBox Validation

Posted by Chetan Pandey <cp...@BLUEsingapore.com>.
Hi Irwan:

Thanks for the reply. 

It did solve my problem but not for the Combo-box which takes ints.

Consider the following:

<td>
<html:select property="attendeeVO.role" >
<html:option value="">Choose Role</html:option>
<html:options collection="roleVector" labelProperty="description"
property="roleId"/> 
</html:select>
</td>


In which we have to set the property called attendeeVO.role which is an int.

Its initial values come from roleVector which holds a String and int pair of
values.

The String is displayed but only the int is returned.

I am Trying the following in my validation.xml :
             <field
                property="attendeeVO.role"
                depends="required">
                    <arg0 key="attendee.role"/>
            </field>
However, even if a value other than "Choose Role" such as Hotel GM,  Hotel
Staff is chose I still get a Validation error message that Role is not
available.

Thanks.

Chetan Pandey


-----Original Message-----
From: Irwan Nurwandi [mailto:irwan.nurwandi@gmail.com] 
Sent: Tuesday, August 01, 2006 1:11 PM
To: Struts Users Mailing List
Subject: Re: Struts ComboBox Validation

>
> But the thing is, since the default value is "Choose Holidex" it considers
> it a String and doesn't validate.

it's should be
<html:option value="">Choose Holidex</html:option>

not this one ...
<html:option value="Choose Holidex"> </html:option>

Regards
IN

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org






---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts ComboBox Validation

Posted by Irwan Nurwandi <ir...@gmail.com>.
>
> But the thing is, since the default value is "Choose Holidex" it considers
> it a String and doesn't validate.

it's should be
<html:option value="">Choose Holidex</html:option>

not this one ...
<html:option value="Choose Holidex"> </html:option>

Regards
IN

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org