• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

validating radio buttons using validator or validation-ruls.xml

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
To do a great right, do a little wrong - shakepeare. twisted little ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic