File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts 2: mathematical operations on status.index Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2: mathematical operations on status.index" Watch "Struts 2: mathematical operations on status.index" New topic
Author

Struts 2: mathematical operations on status.index

vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
i have written 2 iterators with a textfield inside the inner iterator as shown below:



the name attribute (added_by) of the textfield is an array. the above code will fail because value of inner.index will reset to 0 on every iteration of outer loop. how to set index value to (inner.index * outer.index + inner.index)? i tried writing this mathematical formula to array index but it does not work. please help me in resolving it. Thanks.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Without knowing what you did that didn't work it's more difficult to help. I haven't had any issues doing simple expressions in OGNL.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm not sure your formula is right, either; don't you want the outer index * outer size + inner index?
vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
i tried below code:



but it does not work and displaying the formula as text on viewing it in the HTML source.

my formula might be wrong. i will check it again.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You're using essentially random OGNL syntax. The "#" needs to be before each local variable (unless you're using S2.1+, in which case you may or may not need it at all).
vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
thanks newton. it works after adding #.

and as you stated the correct formula is index * inner size + inner index. but now the problem is getting the size value of inner iterator.

I checked IteratorStatus API but there is no size property. i tried the size property of list, but, both second.size and second.length are returning null values. so, how can i get the size of the inner iterator? please guide me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 2: mathematical operations on status.index
 
Similar Threads
set value of a property as another property
How to find Index of an ArrayList in struts 2
Struts2 - <s:iterator> in two-Dimensional Array.
Struts 2 - conditional check of IteratorStatus inside an s:if tag
Struts2 nested iterators with listboxes