• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Iterating a Array in Struts2

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

When i Use value="someStringArray[%{#someStringArrayStatus.index}]"
it prints someStringArray[0],someStringArray[1],someStringArray[2] in the text fields instead of the actual value

when i try value="%{someStringArray[%{#someStringArrayStatus.index}]}"
the page is not at all rendered

I am new to Struts2 n trying to figure the mistake I am doing, any help is greatly appreciated!

Thanks for your time
Filename: temp2deltenames.bmp
Description: The Way it should be on the jsp page
File size: 82 Kbytes
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Too many colors, not enough code tags.

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.

If you're just trying to use the current value of iteration as the textfield value, use the "id" (or "var", depending on version) attribute and use that.
 
Vamshi Jampala
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for letting me know about the code tags,
will try var and will let you know
thanks again for your time.
 
Vamshi Jampala
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried using var but no luck, it just prints me the var in the text fields.
 
Vamshi Jampala
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for convenience attached the image as how its displayed on jsp
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you use the var attribute, then it should work
 
Vamshi Jampala
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ankit,

You were absolutely Right, previously i wasn't using the var properly,



will do the trick
Where can I find the proper explanation on when to use % and # ?

Thanks for your time
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"%{}" is just the OGNL escape sequence, like ${} is for JSP EL. It's occasionally optional, but most people prefer to use it explicitly to avoid any confusion.

The "#" character is used to refer to named value stack objects; it's also not always required, particularly in S2.1+... but it's also fairly inconsistent; I still use it most of the time to avoid confusion.
 
Vamshi Jampala
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I have much more clear picture of what is used for what, thankyou guys

http://struts.apache.org/2.0.14/docs/ognl.html
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic