• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confusion in Struts 2 tag reference

 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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??
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See? We're doing it to help you!

Honest!
 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic