aspose file tools*
The moose likes Struts and the fly likes couldn't get value back from <s:iterator> after submitting the <s:form> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "couldn Watch "couldn New topic
Author

couldn't get value back from <s:iterator> after submitting the <s:form>

will zhang
Ranch Hand

Joined: Sep 11, 2008
Posts: 46
Dear all, I'm using struts 2.0.11

I want to display the iterated object called "Segment" and user can change the fields of it and submit so that the list will be updated.

code in action:

jsp code:

There's no problem in display, however, when the user click "Update" button, it returns an empty arrayList segmentList ([]) to the action.

I tried different method such as
Display is ok, still no value back.

Any solution for this problem? Thanks!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Try using array notation (index inside square brackets, like [n]) if order is important. At some point that may have stopped being a requirement--I noticed that it wasn't strictly necessary, but I don't know if it was always like that, or if it was a change.
will zhang
Ranch Hand

Joined: Sep 11, 2008
Posts: 46
David Newton wrote:Try using array notation (index inside square brackets, like [n]) if order is important. At some point that may have stopped being a requirement--I noticed that it wasn't strictly necessary, but I don't know if it was always like that, or if it was a change.


Thanks, Dave, I used
and it works for form tags, such as textfield, hidden.

However, it doesn't work for data tags(such as<s:property> tag) and ajax tags(such as <s:datetimepicker> tag).
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It works for <s:property> tags if there's a backing collection; not sure what you mean: property tags aren't form tags.
will zhang
Ranch Hand

Joined: Sep 11, 2008
Posts: 46
David Newton wrote:It works for <s:property> tags if there's a backing collection; not sure what you mean: property tags aren't form tags.


I tried but it didn't work, I get nothing even in the display.

When I said property tags aren't form tags, I mean user doesn't change value for ><s:property>, also from this catagory: http://struts.apache.org/2.0.14/docs/tag-reference.html
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You're improperly embedding OGNL escapes; you'd want %{segmentList[#stat.index]} or something like that (if you even need the #; depends on which S2 version you're using).
will zhang
Ranch Hand

Joined: Sep 11, 2008
Posts: 46
David Newton wrote:You're improperly embedding OGNL escapes; you'd want %{segmentList[#stat.index]} or something like that (if you even need the #; depends on which S2 version you're using).


Thanks, Dave, I tried <s:property value="%{segmentList[#stat.index].comment}" /> and found it displays value well but couldn't pass value back to the segmentList.

I also tried <s:property value="segmentList[#stat.index].comment" />, it's the same with above.

segmentList[stat.index] doesn't work for me, even for the display.
jainitya jaiyswal
Greenhorn

Joined: Mar 28, 2011
Posts: 10
Hi
I am also getting the same problem as
couldn't get value back from <s:iterator> after submitting the <s:form>
I have tried the code below
<s:iterator value="shopLog.selllogs" status="SellLogs">
<tr align="left" valign="top">


<td><s:textarea name="%{'shopLog.selllogs['+#SellLogs.index+'].receive'}" id="receive" value="%{receive}" onchange="Total_Day_Stock();" /></td>


</tr>
</s:iterator>
it work fine for display but returning null values in action ,
Please suggest if I am missing something here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: couldn't get value back from <s:iterator> after submitting the <s:form>