• 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

Confusion in Struts 2 tag reference

 
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
According to tag-syntax, String attributes are not evaluated and non-string attributes are evaluated as OGNL.

1. All String attribute types are parsed for the "%{ ... }" notation.
2. All non-String attribute types are not parsed, but evaluated directly as an expression
3. The exception to rule #2 is that if the non-String attribute uses the escape notion "%{}", the notation is ignored as redundant, and the content evaluated.


But in the tag reference of many tags, some attributes are marked as String but they are actually evaluated. Like in checkboxlist, list and value attributes are evaluated as OGNL by default but they are marked as of type String. This confuses me a lot. Am I missing something here or is this a problem with the documentation??
 
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
Probably both ;)

The documentation hasn't been particularly good on stating which attributes are always evaluated regardless of "%{}" notation--I'm not really sure why. The stance of others has been "always wrap OGNL in '%{}' escapes"; I'm now in that camp, just to avoid confusion. Think of it like JSP EL--you always need it.
 
Ankit Garg
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

David Newton wrote:The stance of others has been "always wrap OGNL in '%{}' escapes"; I'm now in that camp, just to avoid confusion.


Yes I'm also of that opinion, I use %{} whether or not the attribute accepts String or Object, still I though that the documentation seemed wrong/misleading a little. But by not providing info about which attributes accept Object, it actually encourages people to use the %{} syntax :wink: .
 
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
See? We're doing it to help you!

Honest!
 
Ankit Garg
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic