Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.2.9
-
None
-
None
Description
The name attribute of a <nested:text indexed="true"> is not rendered properly when is placed inside two nested <nested:iterate>.
Example:
"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()
;
public List setGroups(List groups)
;
};
class Group {
private List users = new LazyList.decorate(new ArrayList(), new UsersFactory());
public List getUsers()
;
public List setUsers(List users)
;
};
class User {
private String name;
public String getName()
public void setName(String name)
{ this.name = name; }};
Data (pseudo-code):
myForm
groups = {
Group(users =
),
Group(users =
)
}
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">
</nested:iterate>
</nested:iterate>
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;}