wood burning stoves 2.0*
The moose likes Struts and the fly likes struts 2 tag accessible data in scriptlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 2 tag accessible data in scriptlet" Watch "struts 2 tag accessible data in scriptlet" New topic
Author

struts 2 tag accessible data in scriptlet

Whit Fairgoose
Greenhorn

Joined: Feb 24, 2011
Posts: 2
I was wondering if there is a way to share data from a Action class to a scriptlet in my jsp. I can access what I want using struts tags <s:property value="tempBean.myVar" /> but I want to be able to get to the 'tempBean' from a scriptlet. I haven't found any real data on this from searching. The 'tempBean' object is a private field of my action class and has public getters/setters.
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
Try this in your scriptlet:



Once you get the stack you can use it to do the same look ups that you do with your struts tags.

You'll also need these 2 page directives to include the classes (plus what ever you need for your own classes):

Whit Fairgoose
Greenhorn

Joined: Feb 24, 2011
Posts: 2
You sir are a stealy eyed missile man. Thank you. For some reason my version the import is a little different com.opensymphony.xwork2.ognl.OgnlValueStack, but it works!
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
I'm using an old version of struts2/xwork, I guess the moved it to a new package. Glad I could help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts 2 tag accessible data in scriptlet