• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Struts Validation with ArrayLiist of beans

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to validate wether user selected a check box or not.
In jsp I have a collection of beans and displaying as follows.

<html:form action="/edit.do?method=edit">
<logic:iterate indexId="i" id="collection" name="dataForm" property="collection">
<%if (i.intValue()%2 == 0)
{%>
<tr>
<%}else{%>
<tr bgcolor=#C0C0C0>
<%}%>


<td>
<html:checkbox name="collection" property="sceneid" indexed="true"/>

</td>
<td>
<bean:write name="collection" property="personid" />

</td>
</tr>
</logic:iterate>
<tr><td><html:submit styleClass="button" property="edit">Edit</html:submit><td>
</html:form>

When I submit it is calling action class and edit method and returning the forward jsp. But it sgould validate.

Here is my validate.xml file

<form name="/edit">
<field property="sceneid" indexedListProperty="collection" depends="required">
<arg0 key="Select the check box" resource="false"/>

</field>
</form>

"/edit" is my action path name. I am not using formName but I tried with form name also.

Action Class :
public class LifeAAction extends DispatchAction {
public ActionForward edit(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {


return mapping.findForward("edit");
}
}
 
sudhakar Tadepalli
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can some one take a look at this please
 
sudhakar Tadepalli
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Helooo, Any help on this please ?
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you show us action-mappings definition for LifeAAction ?
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, you should be using c:if tag for your if statement and not scriptlets.

Have you gotten anything else in this form to validate?

Are you trying to validate that one or more is being checked?
[ August 08, 2005: Message edited by: Kerry Wilson ]
 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your action needs to extend ValidatorAction.

My Bad, form needs to extend ValidatorForm.
[ August 08, 2005: Message edited by: Kerry Wilson ]
 
sudhakar Tadepalli
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kerry, I will use C:if tag later after make it work. This is a test page, I may have some more validation on the form. But for now I am checking if user selects atleast on check box (Required), Then I want to check if user selects more than one check box and clicked edid button I should validate to show he can only select one check box.

Cendy,

Here is the mapping.

<action path="/edit" type="com.amfam.lifewkfl.web.actions.LifeAAction"
name="dataForm" scope="session" parameter="method" validate="true" input="page.lifeA">
<forward name="edit" path="page.edit" />
</action>
 
sudhakar Tadepalli
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heloo...knock..knock...who is there ?..have a look
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic