wood burning stoves 2.0*
The moose likes Struts and the fly likes struts2 iterator problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts2 iterator problem" Watch "struts2 iterator problem" New topic
Author

struts2 iterator problem

geeta kumari gonchala
Greenhorn

Joined: Jan 07, 2009
Posts: 9
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 ]


Thanks in advance
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684


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.



Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
geeta kumari gonchala
Greenhorn

Joined: Jan 07, 2009
Posts: 9
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

Joined: Sep 07, 2008
Posts: 684


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

Joined: Jan 07, 2009
Posts: 9
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>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts2 iterator problem
 
Similar Threads
validation in struts2
problem with struts2 checkbox
Multiple checkboxes and Struts2
Struts2 Iterator
setting scope of variable in Struts2