//The action class contains a (dynamically populated) collection such as
persons defined here
@Result(name="list", value="listPeople.action",
type=ServletRedirectResult.class)
public class EditPersonAction extends ActionSupport {
ArrayList<Person> persons = new ArrayList()
<snip>
}
//then the jsp makes reference to persons ArrayList from the action class and
references specific rows by utilising stat.index by the s:iterator iterator
<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>
this would achieve the effect of dynamically populating n number of Person
objects
does this answer the question?
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: Mon, 3 May 2010 09:08:29 -0500
> From: [email protected]
> To: [email protected]
> Subject: Re: input fields with dynamic names
>
> Bump. Any other ideas?
>
> mitch
>
>
> Mitch Claborn wrote:
> > That works for setting parameter names, but not so well when the tags
> > in the JSP need to retrieve the value for display in the page,
> > particularly if there is a validation error. If there is a static
> > field named "fred" and the action has a "getFred()" method, then all
> > is good. But the field names in my case are dynamic, so I can't have
> > a getNNNNN for all of the dynamic fields.
> >
> > mitch
> >
> >
> > Greg Lindholm wrote:
> >> You are probably looking for ParameterAware
> >>
> >> http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/interceptor/ParameterAware.html
> >>
> >>
> >>
> >>
> >> On Wed, Apr 28, 2010 at 12:47 PM, Mitch Claborn <[email protected]>
> >> wrote:
> >>
> >>> I'm sure I've seen the answer to this somewhere, but darned if I can
> >>> find it
> >>> now when I need it!
> >>>
> >>> I have a page that allows edits of various options, the names of
> >>> which are
> >>> dynamically retrieved from the database. If I have the code in the
> >>> JSP as
> >>> below, the value displayed in the text field is always that from the
> >>> database. If there is a validation error, the user's input value is
> >>> not
> >>> maintained as it would be if there were an explicit getter/setter
> >>> for each
> >>> option name. Is there a way to code the Action (or the JSP) so that
> >>> the
> >>> value shown is the user's input value if there is an error?
> >>>
> >>> <s:iterator value="authorizedOptions" id="o">
> >>> <s:textfield size="10" name="${o.optionName}"
> >>> id="${o.optionName}" value="${o.valueInt}" />
> >>>
> >>> Mitch
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [email protected]
> >>> For additional commands, e-mail: [email protected]
> >>>
> >>>
> >>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [email protected]
> >> For additional commands, e-mail: [email protected]
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
_________________________________________________________________
The New Busy is not the old busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3