ognl - Is the ValueStack life cycle across the application in struts2? -
i can set property on valuestack
in several ways.
valuestack stack = actioncontext.getcontext().getvaluestack(); stack.getcontext().put("resultdto",resultdto); //1. creates different branch //parallel root stack.set("resultdto", resultdto); //2. pushes on root map? stack.push(resultdto); //3. pushes on root myactionclass.setproperty(); //4. normal action accessor
i need able these values in jsp, freemarker , java
stack.findvalue() or stack.findstring().
i want know life cycle of each of these 4 setting methods. across application. valuestack created every request , application , session values set in every request?
i know 4th method common approach may not using in places, action class not accessible.
i have doubt accessing in jsp
<s:push value="resultdto" ><s:property value="data.form1[0]" /></s:push> <!--5.works context.put() & stack.set() both--> <s:property value="#resultdto.data.form1[0].countryofissue" /> <!--6.context.put()--> <s:property value="resultdto.data.form1[0].countryofissue" /> <!--7.stack.set()--> <s:property value="data.form1[0].countryofissue" /> <!--8.stack.push()-->
i want know how 5th point works in both stack.getcontex().put()
, stack.set()
? understand in 6th resultdto accessing, different root , in 7th, it's child of default root, valuestack. in 8th starts search default root.
i went through http://struts.apache.org/2.0.11.1/docs/ognl.html, http://struts.apache.org/2.1.2/struts2-core/apidocs/com/opensymphony/xwork2/util/valuestack.html , rather confusing link http://www.opensymphony.com/ognl/html/developerguide/introduction.html#embeddingognl
having said these little inclined using stack.getcontext().put()
method can see values in setting url ?debug=browser. advise me if going wrong.
the valuestack
per-request. if place values on stack, accessible later in request (i.e., in view layer), not survive redirect, new http request , have own valuestack
.
under normal conditions, parameters in url or in form post set on action using action's setter methods. in interceptor, can add values directly stack. example, exceptionmappinginterceptor
uses stack.push(object)
method publish exceptions use on error pages.
stack.getcontext().put(string, object)
-- places key/value map lives on stack. map represents context of stack.stack.set(string, object)
-- places key/value map lives on stack. i'm not sure how relates previous method, other different map.stack.push(object)
-- places object on root of stack.
you shouldn't need place on stack within view layer, i'm curious trying necessitates that.
Comments
Post a Comment