This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts 2 tag accessible data in scriptlet

 
Whit Fairgoose
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using an old version of struts2/xwork, I guess the moved it to a new package. Glad I could help.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic