How are the person objects being populated? here is the sample configuration from showcase:
<action name="enterPersonsInfo" method="input" class="org.apache.struts2.showcase.conversion.PersonAction"> <result>enterPersonInfo.jsp</result> </action> <action name="submitPersonInfo" method="submit" class="org.apache.struts2.showcase.conversion.PersonAction"> <result>showPersonInfo.jsp</result> <result name="input">enterPersonInfo.jsp</result> </action> <action name="showPersonJspCode"> <result type="plainText">/conversion/enterPersonInfo.jsp</result> </action> <action name="showPersonActionJavaCode"> <result type="plainText">/conversion/PersonAction.java.txt</result> </action> <action name="showPersonJavaCode"> <result type="plainText">/conversion/Person.java.txt</result> </action> here is enterPersonInfo.jsp which is used for all results to/fro enterPersonsInfo action input method <%...@taglib prefix="s" uri="/struts-tags" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Showcase - Conversion - Populate Object into Struts' action List</title> </head> <body> <p/> An example populating a list of object (Person.java) into Struts' action (PersonAction.java) <p/> See the jsp code <s:url var="url" action="showPersonJspCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> See the code for PersonAction.java <s:url var="url" action="showPersonActionJavaCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> See the code for Person.java <s:url var="url" action="showPersonJavaCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> <p/> <s:actionerror /> <s:fielderror /> <s:form action="submitPersonInfo" namespace="/conversion" method="post"> <%-- The following is done Dynamically --%> <s:iterator value="new int[3]" status="stat"> <s:textfield label="%{'Person '+#stat.index+' Name'}" name="%{'persons['+#stat.index+'].name'}" /> <s:textfield label="%{'Person '+#stat.index+' Age'}" name="%{'persons['+#stat.index+'].age'}" /> </s:iterator> <%-- The following is done statically:- --%> <%-- <s:textfield label="Person 1 Name" name="persons[0].name" /> <s:textfield label="Person 1 Age" name="persons[0].age" /> <s:textfield label="Person 2 Name" name="persons[1].name" /> <s:textfield label="Person 2 Age" name="persons[1].age" /> <s:textfield label="Person 3 Name" name="persons[2].name" /> <s:textfield label="Person 3 Age" name="persons[2].age" /> --%> <s:submit /> </s:form> </body> </html> //here is the PersonAction.java used in showcase webapp /* * $Id: PersonAction.java 471756 2006-11-06 15:01:43Z husted $ * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.struts2.showcase.conversion; import java.util.List; import com.opensymphony.xwork2.ActionSupport; /** * */ public class PersonAction extends ActionSupport { private List persons; public List getPersons() { return persons; } public void setPersons(List persons) { this.persons = persons; } public String input() throws Exception { return SUCCESS; } public String submit() throws Exception { return SUCCESS; } } the important bits are jsp reference to persons list here <s:iterator value="new int[3]" status="stat"> <s:textfield label="%{'Person '+#stat.index+' Name'}" name="%{'persons['+#stat.index+'].name'}" /> <s:textfield label="%{'Person '+#stat.index+' Age'}" name="%{'persons['+#stat.index+'].age'}" /> </s:iterator> which references and iterates thru the List of persons from PersonAction private List persons; Action class does push its attributes on to OGNLstack so a reference such as "%{'persons['+#stat.index+'].name'}" works provided you have set stat to be the 'status' index Martin Gainty ______________________________________________ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Date: Thu, 12 Nov 2009 13:16:08 +0100 > From: carl.ballant...@cast-info.es > To: user@struts.apache.org > Subject: Re: Property Mapping in a iterator > > Hi Alex, > > I think you might need to add <constant name="struts.devMode" > value="true" /> in your struts.xml file. > > > > Quoting Alex Parvulescu <alex.parvule...@gmail.com>: > > > hello, > > > > I have been looking at Struts2 for a couple of days now, it seems nice > > and easy to work with. > > > > I have a problem that I don't really understand, maybe I'm missing > > some config settings or something. > > > > Let's say that I want to display a list of persons, and for each > > person I want to see the name. > > This is very straightforward: > > > > <s:iterator value="people" var="p"> > > <div id="row_<s:property value="id"/>"> > > <s:property value="name" /> > > </div> > > </s:iterator> > > > > Easy enough, but if I miss-spell the property name, I get no error, > > only a blank value. > > Is there a struts way to prevent these kinds of things from happening > > - like get some sort of error message. > > > > By the way, I am using Struts 2.1.6 and I'm not sure if this is the > > proper mailing list for this framework. Are you guys dealing with both > > Struts and Struts2 issues? As I've seen so far, Struts2 is pretty > > different than Struts. > > > > If I'm not in the proper place, please point me in the right direction. > > > > thanks, > > alex > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > _________________________________________________________________ Hotmail: Trusted email with Microsoft's powerful SPAM protection. http://clk.atdmt.com/GBL/go/177141664/direct/01/ http://clk.atdmt.com/GBL/go/177141664/direct/01/