I'll pick this up on Monday, thanks for your suggestions Cheers, Phil
On Fri, Mar 5, 2010 at 6:28 PM, Freddy Daoud <xf2...@fastmail.fm> wrote: > Hi Phil, > > Just got a working example. Things for you to try out: > > * the @ValidateNestedProperties({...}) belongs on the private > List<Person> people field, the getter method, or the setter method, > not on the event handler; > > * make sure that you have a public no-args constructor, public > Person() {}, in the Person class; > > * if nothing solves the problem, compare with my code below. > > -- HomeActionBean.java -- > public class HomeActionBean extends BaseActionBean { > private List<Person> people; > public List<Person> getPeople() { > return people; > } > public void setPeople(List<Person> people) { > this.people = people; > } > > �...@defaulthandler > public Resolution index() { > people = new ArrayList<Person>(); > people.add(new Person("name1", "email1")); > people.add(new Person("name2", "email2")); > return new ForwardResolution("/index.jsp"); > } > > public Resolution update() { > System.out.println("people: " + people); > return new ForwardResolution("/index.jsp"); > } > } > > -- index.jsp -- > <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> > <%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld" > %> > > <table> > <stripes:form beanclass="example.action.HomeActionBean" method="POST"> > <c:forEach items="${actionBean.people}" var="person" varStatus="loop"> > <tr> > <td><stripes:text name="people[${loop.index}].name" > value="${person.name}"/></td> > <td><stripes:text name="people[${loop.index}].email" > value="${person.email}"/></td> > </tr> > <c:set var="newIndex" value="${loop.index + 1}" scope="page"/> > </c:forEach> > <tr> > <td><stripes:submit name="update" value="update"/></td> > </tr> > > </stripes:form> > </table> > > -- Person.java -- > public class Person { > public Person() { } > public Person(String name, String email) { setName(name); setEmail(email); } > private String name; > public String getName() { > return name; > } > public void setName(String name) { > this.name = name; > } > private String email; > public String getEmail() { > return email; > } > public void setEmail(String email) { > this.email = email; > } > �...@override > public String toString() { > return name + " " + email; > } > } > > Let me know what you find. > > Cheers, > Freddy > > - > - Sure thing Freddy, actionBean: > - > - private List<Person> people; > - > - //called in default 'view' handler method so intial form is > - populate with people data that can be updated > - public void prepareView(){ > - people = new ArrayList<Person>(); > - people.add(new Person("tom","t...@...")); > - people.add(new Person("harry","ha...@...")); > - people.add(new Person("adrian","adr...@...")); > - people.add(new Person("julie","ju...@...")); > - people.add(new Person("sue","s...@...")); > - } > - > - private List<Person> people; > - > - @ValidateNestedProperties ({ > - @Validate(field="name", required=true, minlength=3, > - maxlength=15, on="update"), > - �...@validate(field="email", required=true > - ,mask="[\\w\\...@[\\w\\.]+\\.\\w+", on="update") > - }) > - @HandlesEvent("update") > - public Resolution updatePeople(){ > - logger.info("people updated :" + people); > - return new RedirectResolution(WelcomeActionBean.class,"view"); > - } > - > - public List<Person> getPeople() { > - return people; > - } > - > - public void setPeople(List<Person> people) { > - this.people = people; > - } > - > - JSP: > - > - <stripes:form > beanclass="com.orangehome.ui.action.admintools.ExampleActionBean" > - method="POST"> > - <c:forEach items="${actionBean.people}" var="person" > varStatus="loop"- > - <tr> > - <td><stripes:text name="people[${loop.index}].name" > - value="${person.name}"/></td> > - <td><stripes:text name="people[${loop.index}].email" > - value="${person.email}"/></td> > - </tr> > - <c:set var="newIndex" value="${loop.index + 1}" > scope="page"/- > - </c:forEach> > - <stripes:submit name="update" value="update"/> > - </stripes:form> > - > - Stripes is falling over in PropertyExpressionEvaluation.java:652, > - looks like it's trying to instantiate a primitive (the index) : > - > - Class clazz = convertToClass(node.getValueType(), node); > - > - if (clazz.isArray()) { > - return Array.newInstance(clazz.getComponentType(), 0); > - } > - else if (clazz.isEnum()) { > - return clazz.getEnumConstants()[0]; > - } > - else if (clazz.isInterface() ) { > - return ReflectUtil.getInterfaceInstance(clazz); > - } > - else { > - return clazz.newInstance(); > - } > - > - Cheers, > - Phil > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Stripes-users mailing list > Stripes-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/stripes-users > ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Stripes-users mailing list Stripes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/stripes-users