• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2: mathematical operations on status.index

 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure your formula is right, either; don't you want the outer index * outer size + inner index?
 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic