File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Confusion in Struts 2 tag reference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Confusion in Struts 2 tag reference" Watch "Confusion in Struts 2 tag reference" New topic
Author

Confusion in Struts 2 tag reference

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

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??


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Aug 03, 2008
Posts: 9291
    
  17

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

Joined: Sep 29, 2008
Posts: 12617

See? We're doing it to help you!

Honest!
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Confusion in Struts 2 tag reference
 
Similar Threads
struts 2 design problem
Struts 2: %{} or #
<s:set /> tag problem in Struts2
pass value
struts radio button default checked issue.