aspose file tools
The moose likes Struts and the fly likes Problem with struts <s:select list> validation? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "Problem with struts <s:select list> validation?" Watch "Problem with struts <s:select list> validation?" New topic
Author

Problem with struts <s:select list> validation?

Shrikant Deshpande
Greenhorn

Joined: May 17, 2010
Posts: 15
Problem with <s:select list> validation?


In my jsp page I have list of mentors coming from session.

<s:select list="#allmentors" name="mentorName" headerKey="1" headerValue="-- Select Mentor --"
key="createlabel.selectmentor"/>


Below is the code for my actionclass-validation.xml file.

<field name="mentorName">
<field-validator type="requiredstring">
<message>Please select the mentor</message>
</field-validator>
</field>


In my JSP page,select list shows list of mentors.
If I do not select any mentor name, it shows validation message "Please select the mentor".

But when I select any mentor name from list, it shows the same message "Please select the mentor."

How to do validation for <s:select list>.. ?

If user do not select any mentor from list,then it must display the validation message.

But if user selects any mentor name from list, it should not display validation message.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

But you've given it a value. And if you're using numeric values, "requiredstring" doesn't seem like a great validation choice, although I guess it'll work?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with struts <s:select list> validation?
 
Similar Threads
Struts2 validation problem
selecting a value in dropdown
Validating s:select and s:checkbox with struts2 validator
validation for boolean datatype
validation problem in ActionClass-validation.xml