File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes validating radio buttons using validator or validation-ruls.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validating radio buttons using validator or validation-ruls.xml" Watch "validating radio buttons using validator or validation-ruls.xml" New topic
Author

validating radio buttons using validator or validation-ruls.xml

vamshidhar nimbagiri
Ranch Hand

Joined: Oct 04, 2004
Posts: 61
Hi ,

I got radio buttons in my JSP, here i need to show a error message if the user didn't select none of the
radio buttons (condition is: if the enteredFlag="Y" then all radio buttons must be selected else not
required). Here we need to use validation.xml or validator-rules.xml for all validations.But the
problem is here i got a "xesp" which is declared as Obect array in struts-config.xml,
each object[i] will show what the user selected.
1. how to show the message according to the condtion.
2. its showing the 9 messages if user didn't select 9 options.(it should show only message saying all must be selected)

here is my jsp example:
<tr>
<td nowrap>
<html:radio name="xxForm" property="xesp[0].xSw" value="Y" /> Yes</td>
<td nowrap>
<html:radio name="xxForm" property="xesp[0].xSw" value="N" /> No</td>
</tr>
<tr>
<td nowrap>
<html:radio name="xxForm" property="xesp[1].xSw" value="Y" /> Yes</td>
<td nowrap>
<html:radio name="xxForm" property="xesp[1].xSw" value="N" /> No</td>
</tr>
.
.
.
.
.till 9..

in validation.xml:
<!-- Every question must be answered, else set error -->
<form name="xForm">
<field property="xResp[0].xSw" depends="required">
<msg name="required" key="xp.xh.xns.required"/>
</field>
<field property="xesp[1].xSw" depends="required">
<msg name="required" key="xp.xh.xns.required"/>
</field>
..
..
.
.
.till 9


Thanks!!
vamshi


Thanks,
Vamshidhar Nimbagiri
SCJP 5.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validating radio buttons using validator or validation-ruls.xml
 
Similar Threads
Radio control in Struts
validation error
headache with validation framework
Checkbox and Multibox validation
problem using validwhen and radio button