aspose file tools*
The moose likes Struts and the fly likes get data from valueStack inside an action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "get data from valueStack inside an action" Watch "get data from valueStack inside an action" New topic
Author

get data from valueStack inside an action

Armin Vetek
Greenhorn

Joined: Aug 21, 2010
Posts: 29
Hi,

I have a jsp page which consists from some criteria fields and jquery-grid. The forms looks like that:
criteria field1 -----------------
criteria field2 -----------------
criteria field3 ------------------
search_button

table - jquery grid
--------------------------------------
--col1 -+- col2 -+- col3 -
--------------------------------------
value1 value2 value3

FormAction is called when search_button is pressed. Values from FormAction are put on ValueStack.
JSonAction which is used to render a jquery grid table is called from the jsp page. I would like to read criteria fields which are stored on ValueStack from another action (JSonAction).

Is it possible to get a value from ValueStack inside an action in struts2?

Regards,
Javanus


http://www.javanus.com/blogs
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Of course--OGNL (and JSTL) resolve against the value stack. That's how Struts 2 works.
Armin Vetek
Greenhorn

Joined: Aug 21, 2010
Posts: 29
Hi,

I understand how to get the value from valueStack in jsp.

I do not know how to get the value from ValueStack inside an action.
Struts ValueStack Debug shows the following:
Value Stack Contents
Object Property Name Property Value
dao.RequestAction status NEW

Code below returns null. I would like to get the value for status field from object dao.RequestAction. I tried the following:
ValueStack stack = ActionContext.getContext().getValueStack();
System.out.println("Status = " + stack.findString("dao.RequestAction"));

Could you give me a tip?

Regards,
Javanus
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: get data from valueStack inside an action
 
Similar Threads
html:link problem
Error DefaultActionInvocation
put the criteria fields on valuestack when move to another page and get them back on return
Send a value from textfield in s:form into the json action
Struts2-json plugin not serializing action class to json