You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Mark Menard <ma...@mjm.net> on 2006/11/17 23:57:34 UTC
Value Stack Question
Is there a means of examining the value stack. I have a very strange
situation where OGNL in my JSP is returning a value from
com.opensymphony.xwork2.ActionContext.parameters on the stack, even though I
have a property with the name on my action class. It's almost like OGNL is
skipping over the property of my action and moving down the stack until it
find my property sitting in the "parameters" Map.
I'd like to be able to dump the stack from top to bottom, listing the names
of the object in the stack, and call toString() and getClass().getName() on
them.
I tried the following in an Interceptor using PreResultListener:
valueStackContext = context.getValueStack().getContext ();
for (Object o : valueStackContext.keySet () ) {
if (o == null) {
System.out.println ("o is null!!!!!!!!!!!!!!!!");
} else {
Object value = valueStackContext.get (o);
System.out.println (o.toString() + ": " +
(value == null ? "null" : value.toString () ) );
System.out.println (o.toString() + ": " +
(value == null ? "null" : value.getClass().getName () ) );
}
}
But, I don't see my action on the stack. Stripping out the toString() output
I see the following:
17:35:27,773 INFO [STDOUT] last.bean.accessed: null
17:35:27,773 INFO [STDOUT] struts.actionMapping:
org.apache.struts2.dispatcher.mapper.ActionMapping
17:35:27,773 INFO [STDOUT] com.opensymphony.xwork2.ActionContext.locale:
java.util.Locale
17:35:27,773 INFO [STDOUT] session:
org.apache.struts2.dispatcher.SessionMap
17:35:27,773 INFO [STDOUT] current.property.path: null
17:35:27,773 INFO [STDOUT] attr: org.apache.struts2.util.AttributeMap
17:35:27,773 INFO [STDOUT]
com.opensymphony.xwork2.ActionContext.application:
org.apache.struts2.dispatcher.ApplicationMap
17:35:27,773 INFO [STDOUT] report.conversion.errors: java.lang.Boolean
17:35:27,773 INFO [STDOUT]
com.opensymphony.xwork2.ActionContext.actionInvocation:
com.opensymphony.xwork2.DefaultActionInvocation
17:35:27,773 INFO [STDOUT] last.property.accessed: null
17:35:27,774 INFO [STDOUT] com.opensymphony.xwork2.ActionContext.session:
org.apache.struts2.dispatcher.SessionMap
17:35:27,774 INFO [STDOUT] application:
org.apache.struts2.dispatcher.ApplicationMap
17:35:27,774 INFO [STDOUT]
com.opensymphony.xwork2.ActionContext.parameters: java.util.HashMap
17:35:27,774 INFO [STDOUT] parameters: java.util.HashMap
17:35:27,774 INFO [STDOUT] com.opensymphony.xwork2.ActionContext.name:
java.lang.String
17:35:27,774 INFO [STDOUT] __link: [Ljava.lang.Object;
17:35:27,774 INFO [STDOUT]
com.opensymphony.xwork2.util.ValueStack.ValueStack:
com.opensymphony.xwork2.util.OgnlValueStack
17:35:27,774 INFO [STDOUT] xwork.MethodAccessor.denyMethodExecution:
java.lang.Boolean
17:35:27,774 INFO [STDOUT]
com.opensymphony.xwork2.dispatcher.HttpServletRequest:
org.apache.struts2.dispatcher.StrutsRequestWrapper
17:35:27,774 INFO [STDOUT] xwork.NullHandler.createNullObjects:
java.lang.Boolean
17:35:27,774 INFO [STDOUT]
com.opensymphony.xwork2.ActionContext.conversionErrors: java.util.HashMap
17:35:27,774 INFO [STDOUT]
com.opensymphony.xwork2.dispatcher.ServletContext:
org.apache.catalina.core.ApplicationContextFacade
17:35:27,774 INFO [STDOUT]
com.opensymphony.xwork2.dispatcher.HttpServletResponse:
com.opensymphony.module.sitemesh.filter.PageResponseWrapper
17:35:27,774 INFO [STDOUT] request:
org.apache.struts2.dispatcher.RequestMap
I don't see an instance of my action class, nor an ActionProxy. I do see the
com.opensymphony.xwork2.util.OgnlValueStack. Is that the actual stack that
is used by OGNL to display the view?
Thanks,
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Re: Value Stack Question
Posted by Mark Menard <ma...@mjm.net>.
On 11/18/06 12:02 PM, "Ian Roughley" <ia...@fdar.com> wrote:
> <ww:debug /> tag should list the stack.
Yea, I'm working with the DebuggingInterceptor at the moment. The issue with
that is it tries to start traversing my whole data model. :( So, I've hacked
on it a little and added a max depth to the serializeIt() method. Setting
that to a reasonable number gets me what I need. Might not work for
everyone. I'm also thinking about hacking on it a bit more so you can
specify via a param what you want it to serialize (ie. context, request,
valuestack, etc.) I just don't know how to access a param that is in the
struts.xml <interceptor> tag. (Another thing to learn.) Also it would be
nice to give it a max depth via configuration. I'm sure I'm not the only
person who's ever had it try to crawl their whole data model.
> Remember that the local vars (from loops & tags) as well as the model will be
> on the stack first - so if the variable has the same name you will need to
> better specify its location.
Something like that is what I'm running into.
I'm working on implementing a "conversation scope" to manage multiple
conversations of the same type for which I need to save state between
screens. I can't just throw the "model" into the session and get it back,
because the user could have multiple "conversations" of the particular type
going on at the same time. I could do this on an ad-hoc basis, on a per
action basis, but I thought a more holistic solution might be worth the
effort. Then I can submit it for inclusion in S2 if there is interest.
Thanks,
Mark
PS: Also thanks to Wendy for pointing me in the direction of the debug
interceptor. :) You very well might have saved my weekend.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Re: Value Stack Question
Posted by Ian Roughley <ia...@fdar.com>.
<ww:debug /> tag should list the stack. Remember that the local vars
(from loops & tags) as well as the model will be on the stack first - so
if the variable has the same name you will need to better specify its
location.
/Ian
Mark Menard wrote:
> Is there a means of examining the value stack. I have a very strange
> situation where OGNL in my JSP is returning a value from
> com.opensymphony.xwork2.ActionContext.parameters on the stack, even though I
> have a property with the name on my action class. It's almost like OGNL is
> skipping over the property of my action and moving down the stack until it
> find my property sitting in the "parameters" Map.
>
> I'd like to be able to dump the stack from top to bottom, listing the names
> of the object in the stack, and call toString() and getClass().getName() on
> them.
>
> I tried the following in an Interceptor using PreResultListener:
>
> valueStackContext = context.getValueStack().getContext ();
> for (Object o : valueStackContext.keySet () ) {
> if (o == null) {
> System.out.println ("o is null!!!!!!!!!!!!!!!!");
> } else {
> Object value = valueStackContext.get (o);
> System.out.println (o.toString() + ": " +
> (value == null ? "null" : value.toString () ) );
> System.out.println (o.toString() + ": " +
> (value == null ? "null" : value.getClass().getName () ) );
> }
> }
>
> But, I don't see my action on the stack. Stripping out the toString() output
> I see the following:
>
> 17:35:27,773 INFO [STDOUT] last.bean.accessed: null
> 17:35:27,773 INFO [STDOUT] struts.actionMapping:
> org.apache.struts2.dispatcher.mapper.ActionMapping
> 17:35:27,773 INFO [STDOUT] com.opensymphony.xwork2.ActionContext.locale:
> java.util.Locale
> 17:35:27,773 INFO [STDOUT] session:
> org.apache.struts2.dispatcher.SessionMap
> 17:35:27,773 INFO [STDOUT] current.property.path: null
> 17:35:27,773 INFO [STDOUT] attr: org.apache.struts2.util.AttributeMap
> 17:35:27,773 INFO [STDOUT]
> com.opensymphony.xwork2.ActionContext.application:
> org.apache.struts2.dispatcher.ApplicationMap
> 17:35:27,773 INFO [STDOUT] report.conversion.errors: java.lang.Boolean
> 17:35:27,773 INFO [STDOUT]
> com.opensymphony.xwork2.ActionContext.actionInvocation:
> com.opensymphony.xwork2.DefaultActionInvocation
> 17:35:27,773 INFO [STDOUT] last.property.accessed: null
> 17:35:27,774 INFO [STDOUT] com.opensymphony.xwork2.ActionContext.session:
> org.apache.struts2.dispatcher.SessionMap
> 17:35:27,774 INFO [STDOUT] application:
> org.apache.struts2.dispatcher.ApplicationMap
> 17:35:27,774 INFO [STDOUT]
> com.opensymphony.xwork2.ActionContext.parameters: java.util.HashMap
> 17:35:27,774 INFO [STDOUT] parameters: java.util.HashMap
> 17:35:27,774 INFO [STDOUT] com.opensymphony.xwork2.ActionContext.name:
> java.lang.String
> 17:35:27,774 INFO [STDOUT] __link: [Ljava.lang.Object;
> 17:35:27,774 INFO [STDOUT]
> com.opensymphony.xwork2.util.ValueStack.ValueStack:
> com.opensymphony.xwork2.util.OgnlValueStack
> 17:35:27,774 INFO [STDOUT] xwork.MethodAccessor.denyMethodExecution:
> java.lang.Boolean
> 17:35:27,774 INFO [STDOUT]
> com.opensymphony.xwork2.dispatcher.HttpServletRequest:
> org.apache.struts2.dispatcher.StrutsRequestWrapper
> 17:35:27,774 INFO [STDOUT] xwork.NullHandler.createNullObjects:
> java.lang.Boolean
> 17:35:27,774 INFO [STDOUT]
> com.opensymphony.xwork2.ActionContext.conversionErrors: java.util.HashMap
> 17:35:27,774 INFO [STDOUT]
> com.opensymphony.xwork2.dispatcher.ServletContext:
> org.apache.catalina.core.ApplicationContextFacade
> 17:35:27,774 INFO [STDOUT]
> com.opensymphony.xwork2.dispatcher.HttpServletResponse:
> com.opensymphony.module.sitemesh.filter.PageResponseWrapper
> 17:35:27,774 INFO [STDOUT] request:
> org.apache.struts2.dispatcher.RequestMap
>
> I don't see an instance of my action class, nor an ActionProxy. I do see the
> com.opensymphony.xwork2.util.OgnlValueStack. Is that the actual stack that
> is used by OGNL to display the view?
>
> Thanks,
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Re: Value Stack Question
Posted by Wendy Smoak <ws...@gmail.com>.
On 11/17/06, Mark Menard <ma...@mjm.net> wrote:
> Is there a means of examining the value stack. I have a very strange
> situation where OGNL in my JSP is returning a value from
> com.opensymphony.xwork2.ActionContext.parameters on the stack, even though I
> have a property with the name on my action class. It's almost like OGNL is
> skipping over the property of my action and moving down the stack until it
> find my property sitting in the "parameters" Map.
>
> I'd like to be able to dump the stack from top to bottom, listing the names
> of the object in the stack, and call toString() and getClass().getName() on
> them.
Would the debug console (or xml) be useful here? (Don?)
http://cwiki.apache.org/confluence/display/WW/Debugging
--
Wendy
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Re: Value Stack Question
Posted by tm jee <tm...@yahoo.co.uk>.
Hi Mark,
By doing
valueStack.getContext();
we get the valueStack's context (a Map) whose value with "someKey" as its key is accessible through
<@s.property value="%{#someKey}" />
There's a root in the value stack as well,
valueStack.getRoot();
which is like a stack, I think that's where the action resides.
rgds
Mark Menard <ma...@mjm.net> wrote: Is there a means of examining the value stack. I have a very strange
situation where OGNL in my JSP is returning a value from
com.opensymphony.xwork2.ActionContext.parameters on the stack, even though I
have a property with the name on my action class. It's almost like OGNL is
skipping over the property of my action and moving down the stack until it
find my property sitting in the "parameters" Map.
I'd like to be able to dump the stack from top to bottom, listing the names
of the object in the stack, and call toString() and getClass().getName() on
them.
I tried the following in an Interceptor using PreResultListener:
valueStackContext = context.getValueStack().getContext ();
for (Object o : valueStackContext.keySet () ) {
if (o == null) {
System.out.println ("o is null!!!!!!!!!!!!!!!!");
} else {
Object value = valueStackContext.get (o);
System.out.println (o.toString() + ": " +
(value == null ? "null" : value.toString () ) );
System.out.println (o.toString() + ": " +
(value == null ? "null" : value.getClass().getName () ) );
}
}
But, I don't see my action on the stack. Stripping out the toString() output
I see the following:
17:35:27,773 INFO [STDOUT] last.bean.accessed: null
17:35:27,773 INFO [STDOUT] struts.actionMapping:
org.apache.struts2.dispatcher.mapper.ActionMapping
17:35:27,773 INFO [STDOUT] com.opensymphony.xwork2.ActionContext.locale:
java.util.Locale
17:35:27,773 INFO [STDOUT] session:
org.apache.struts2.dispatcher.SessionMap
17:35:27,773 INFO [STDOUT] current.property.path: null
17:35:27,773 INFO [STDOUT] attr: org.apache.struts2.util.AttributeMap
17:35:27,773 INFO [STDOUT]
com.opensymphony.xwork2.ActionContext.application:
org.apache.struts2.dispatcher.ApplicationMap
17:35:27,773 INFO [STDOUT] report.conversion.errors: java.lang.Boolean
17:35:27,773 INFO [STDOUT]
com.opensymphony.xwork2.ActionContext.actionInvocation:
com.opensymphony.xwork2.DefaultActionInvocation
17:35:27,773 INFO [STDOUT] last.property.accessed: null
17:35:27,774 INFO [STDOUT] com.opensymphony.xwork2.ActionContext.session:
org.apache.struts2.dispatcher.SessionMap
17:35:27,774 INFO [STDOUT] application:
org.apache.struts2.dispatcher.ApplicationMap
17:35:27,774 INFO [STDOUT]
com.opensymphony.xwork2.ActionContext.parameters: java.util.HashMap
17:35:27,774 INFO [STDOUT] parameters: java.util.HashMap
17:35:27,774 INFO [STDOUT] com.opensymphony.xwork2.ActionContext.name:
java.lang.String
17:35:27,774 INFO [STDOUT] __link: [Ljava.lang.Object;
17:35:27,774 INFO [STDOUT]
com.opensymphony.xwork2.util.ValueStack.ValueStack:
com.opensymphony.xwork2.util.OgnlValueStack
17:35:27,774 INFO [STDOUT] xwork.MethodAccessor.denyMethodExecution:
java.lang.Boolean
17:35:27,774 INFO [STDOUT]
com.opensymphony.xwork2.dispatcher.HttpServletRequest:
org.apache.struts2.dispatcher.StrutsRequestWrapper
17:35:27,774 INFO [STDOUT] xwork.NullHandler.createNullObjects:
java.lang.Boolean
17:35:27,774 INFO [STDOUT]
com.opensymphony.xwork2.ActionContext.conversionErrors: java.util.HashMap
17:35:27,774 INFO [STDOUT]
com.opensymphony.xwork2.dispatcher.ServletContext:
org.apache.catalina.core.ApplicationContextFacade
17:35:27,774 INFO [STDOUT]
com.opensymphony.xwork2.dispatcher.HttpServletResponse:
com.opensymphony.module.sitemesh.filter.PageResponseWrapper
17:35:27,774 INFO [STDOUT] request:
org.apache.struts2.dispatcher.RequestMap
I don't see an instance of my action class, nor an ActionProxy. I do see the
com.opensymphony.xwork2.util.OgnlValueStack. Is that the actual stack that
is used by OGNL to display the view?
Thanks,
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Send instant messages to your online friends http://uk.messenger.yahoo.com