Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts2 iterator problem

 
geeta kumari gonchala
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi freinds,

I am new to struts2.It is pretty good to use struts2.I am using Iterator in my jsp to display index using itStatus.I want get that index in my ActionSupport but i am not able to get that value .

<lms:iterator value="patterns" status="itStatus">
<td><lms:property value="#itStatus.getIndex()+1"/></td>
</iterator>

how to get that index value in my ActionSupport .can any body help me.

Thanks in advance.

[ UD: edited to fix RSS problems ]
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

first of all you have to specify your struts property name="" tag.

Then and then you get this value using this name="value" field and get it to action.

Second thing your property tag does not contain name="" tag. It is use only display your value.

So, use textfield make it readonly="true" give it to name="XYZ" tag and then get it in Action using

request.getparameter("XYZ");

<lms:property value="#itStatus.getIndex()+1"/> this tag you have to change.


 
geeta kumari gonchala
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for your reply.

But i cant use textfields here .even if i use them .in my code i trying to get iterator by using href .

seet this once.

<lms:iterator value="testWebList" status="itStatus">
<tr>
<td><a href="currentIndex.action" ><lms:property value="index+1"/><a/></td>
</tr>

</lms:iterator>

so that i'm not able to get that index value
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

Any how <s:property not give you value at Action.

Because in Action if you want value any variable then at least you have name of this variable.

And property tag have not name.

><s:property is you only display your variable at jsp. >
 
geeta kumari gonchala
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am able to get the index .thank you for your help

this is the code i'm using to get index.

<lms:iterator value="testWebList" status="itStatus">
<tr>
<td>
<!--
<a href="currentIndex.action"> <lms:property value="index + 1"/> <a/> -->


<lms:url id="currentIndex" action="currentIndex">
<lms:param name="currentIndex" value="index"/>
</lms:url>

<lms:a href="%{currentIndex}"> <lms:property value="index + 1"/> </lms:a>

</td>

</tr>

</lms:iterator>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic