Hello, If I have a jsp file with an undeterminated number of components, how can I use the ActionForm validation with parametred name fields ? Is it possible with struts ? How ?
example : I want the user put the surname and name of n men in a form, and use a form without create n instance values. ********* myFile.jsp ********* <%@ page language="java" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <% int number = Integer.parseInt( (Integer) request.getAttribute("number")); %> <html:html locale="true"> <head> <title>Test</title> </head> <body> <html:errors/> <html:form action="/MyAction.do"> <table> <% for(int i=0, i<number, i++){ %> <tr> <td>Surname :</td> <td> <html:text property="surname<%=i%>" /> </td> </tr> <tr> <td>Name :</td> <td> <html:text property="name<%=i%>" /> </td> </tr> <% } %> <tr> <td> <html:submit property="submit" value="submit"/> </td> <td> <html:reset/> </td> </tr> </table> </html:form> </body> </html:html> ****** MyActionForm.java ****** package myStrutsProject.form; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.*; import myStrutsProject.commun.*; public final class MyActionForm extends ActionForm { private String surname; private String name; // Getters & Setters public String getSurname() { return surname; } public String setName(String name) { this.name = name; } public String getName() { return name; } public String setName(String name) { this.name = name; } public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (surname = null || name = null) { errors.add("name and surname required", new ActionError("error.surnameAndNameRequired")); } return errors; } } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>