You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Per Jørgen Walstrøm <pe...@statnett.no> on 2005/11/23 11:43:07 UTC
nested:iterate and setting of parameter
hello,
I use Struts 1.2.7 and in my jsp, I have the following nested elements:
<nested:iterate id="sectionGroupElement" name="crudOutageForm" property="geSectionGroups">
<nested:iterate id="sectionGroupCommentsElement" name="sectionGroupElement" property="geSectionGroupComments">
<bean:message key="crudOutage.comment"/>:
<nested:textarea name="sectionGroupCommentsElement" property="geComment.remark"/>
</nested:iterate>
</nested:iterate>
my form, crudOutageForm, contains the following fields, with getters and setters:
private Collection geSectionGroups;
this collection contains objects of GeSectionGroup. In GeSectionGroup.java, I have the following field (with getter and setter):
private Set geSectionGroupComments;
geSectionGroupComments contains objects of GeSectionGroupComment. In GeSectionGroupComment.java, I have the following field (with getter and setter):
private GeComment geComment;
GeComment.java contains
private String remark;
It is this 'remark' I am trying to set, but I am not succeeding in doing so. When submitting my form, the request parameter is named "geComment.remark", and this of course has no setter in my crudOutageForm. I tried to use the indexed=true attribute, like this
<nested:textarea indexed="true" name="sectionGroupCommentsElement" property="geComment.remark"/>
The request parameter is then named "sectionGroupCommentsElement[0].geComment.remark", which also is not sufficient. I would need something like
geSectionGroups[0].geSectionGroupComments[0].geComment.remark
I may be naive, but I was kind of hoping for Struts to be able to set that "remark"-parameter automagically. Obviously, it doesn't ;-(
Any suggestions?
best regards,
Per
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: nested:iterate and setting of parameter
Posted by "Deshmukh, Prabodh (P.)" <pd...@ford.com>.
Try this:
<nested:root name="crudOutageForm">
<nested:iterate property="geSectionGroups">
<nested:iterate property="geSectionGroupComments">
<bean:message key="crudOutage.comment"/>:
<nested:textarea property="geComment.remark"/>
</nested:iterate>
</nested:iterate>
</nested:root>
This should create request parms like: geSectionGroups[0].geSectionGroupComments[0].geComment.remark.
-----Original Message-----
From: Per Jørgen Walstrøm [mailto:per.walstrom@statnett.no]
Sent: Wed 11/23/2005 5:43 AM
To: user@struts.apache.org
Cc:
Subject: nested:iterate and setting of parameter
hello,
I use Struts 1.2.7 and in my jsp, I have the following nested elements:
<nested:iterate id="sectionGroupElement" name="crudOutageForm" property="geSectionGroups">
<nested:iterate id="sectionGroupCommentsElement" name="sectionGroupElement" property="geSectionGroupComments">
<bean:message key="crudOutage.comment"/>:
<nested:textarea name="sectionGroupCommentsElement" property="geComment.remark"/>
</nested:iterate>
</nested:iterate>
my form, crudOutageForm, contains the following fields, with getters and setters:
private Collection geSectionGroups;
this collection contains objects of GeSectionGroup. In GeSectionGroup.java, I have the following field (with getter and setter):
private Set geSectionGroupComments;
geSectionGroupComments contains objects of GeSectionGroupComment. In GeSectionGroupComment.java, I have the following field (with getter and setter):
private GeComment geComment;
GeComment.java contains
private String remark;
It is this 'remark' I am trying to set, but I am not succeeding in doing so. When submitting my form, the request parameter is named "geComment.remark", and this of course has no setter in my crudOutageForm. I tried to use the indexed=true attribute, like this
<nested:textarea indexed="true" name="sectionGroupCommentsElement" property="geComment.remark"/>
The request parameter is then named "sectionGroupCommentsElement[0].geComment.remark", which also is not sufficient. I would need something like
geSectionGroups[0].geSectionGroupComments[0].geComment.remark
I may be naive, but I was kind of hoping for Struts to be able to set that "remark"-parameter automagically. Obviously, it doesn't ;-(
Any suggestions?
best regards,
Per
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org