Struts ComboBox Validation

2006-07-31 Thread Chetan Pandey
I have the following Combobox in my Struts Application:

 

 

tdbean: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

2006-07-31 Thread Irwan Nurwandi


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Struts ComboBox Validation

2006-07-31 Thread Chetan Pandey
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:[EMAIL PROTECTED] 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






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