struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "bocca romel (JIRA)" <>
Subject [jira] Created: (STR-2991) indexed <nested:text> does not render index properly when inside two nested <nested:iterate>
Date Tue, 02 Jan 2007 19:38:17 GMT
indexed <nested:text> does not render index properly when inside two nested <nested:iterate>

                 Key: STR-2991
             Project: Struts 1
          Issue Type: Bug
          Components: Taglibs
    Affects Versions: 1.2.9
            Reporter: bocca romel

The name attribute of a <nested:text indexed="true"> is not rendered properly when is
placed inside two nested <nested:iterate>.


"A MyForm contains a list of Group, and a Group contains a list of User. I want to edit the
name of all users in a single page, categorized by group":

class MyForm extends ActionForm {
  private List groups = new LazyList.decorate(new ArrayList(), new GroupsFactory());
  public List getGroups() { return groups };
  public List setGroups(List groups) { this.groups = groups; };

class Group {
  private List users = new LazyList.decorate(new ArrayList(), new UsersFactory());
  public List getUsers() { return users};
  public List setUsers(List users) { this.users = users; };

class User {
  private String name;
  public String getName() { return name;}
  public void setName(String name) { = name; }

Data (pseudo-code):
    groups = { 
      Group(users = { "user1", "user2", "user3"}),
      Group(users = { "user4", "user5", "user6"})

I want to render this:

<input type="text" name="groups[0].users[0].name" value="user1">
<input type="text" name="groups[0].users[1].name" value="user2">
<input type="text" name="groups[0].users[2].name" value="user3">
<input type="text" name="groups[1].users[0].name" value="user4">
<input type="text" name="groups[1].users[1].name" value="user5">
<input type="text" name="groups[1].users[2].name" value="user6">

The following code (code1):

<nested:iterate name="myForm" property="groups">
  <nested:iterate property="users" >
    <nested:text property="name" indexed="true">

renders this:

<input type="text" name="myForm[0].groups[0].users[0].name" value="user1">
<input type="text" name="myForm[1].groups[0].users[1].name" value="user2">
<input type="text" name="myForm[2].groups[0].users[2].name" value="user3">
<input type="text" name="myForm[0].groups[1].users[0].name" value="user4">
<input type="text" name="myForm[1].groups[1].users[1].name" value="user5">
<input type="text" name="myForm[2].groups[1].users[2].name" value="user6">

I don't know how to avoid to render the "myForm[i]" part. The only solution I have found is
to add the following getter into MyForm class. It works, but seems ugly: public BorrameForm
getForm(int index) {return this;}

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


View raw message