Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
will zhang
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic