• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Struts 2: mathematical operations on status.index

 
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.
 
Author
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
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
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.
 
Ruth Stout was famous for gardening naked. Just like this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic