struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ted Husted" <hus...@apache.org>
Subject Re: getting namespace of action through OGNL
Date Mon, 07 Jan 2008 20:46:12 GMT
I could see an argument for exposing the namespace as an attribute in
the normal course.

If nothing else, I wonder if we should roll this functionality into
the SiteMesh plugin.

-Ted.

On Jan 7, 2008 3:39 PM, Wes Wannemacher <wesw@wantii.com> wrote:
>
> On Mon, 2008-01-07 at 15:20 -0500, Ted Husted wrote:
> > The Action (or an Interceptor) could set it as a property that a tag
> > could then access.
>
> I went ahead and wrote an interceptor. The only problem I have with
> doing it this way though is that the interceptor is doing some magic
> that isn't quite apparent when looking at the JSP / OGNL code.
>
> >
> > We can set properties directly to the stack from an Interceptor. (This
> > is how the validators expose bad input to a typed field.)
> >
> > As a general rule, pages should be as dumb as possible, and only know
> > what the value stack tells it.
>
> Yeah, I agree with that, but in my case this is a sitemesh decorator
> page. I am rendering a menu based on the section of the site they are
> using. Each namespace is like a 'module,' so I figure if the user is
> looking at namespace X, they are presented with a menu that corresponds
> to namespace X. I just didn't realize at design time that there wasn't a
> quick way to get the namespace within OGNL.
>
> >
> > Note that the value stack properties are exposed as request
> > properties, so any property set should be available to the tags and
> > JSTL without any weird OGNL syntax.
> >
>
> I can normally get what I want pretty easily with OGNL. This call was a
> bit more complex but I still don't understand why it doesn't work. I'm
> happy with my current solution, but was hoping someone could explain
> what is wrong with the expression as I had it originally.
>
> -Wes
>
>
> > HTH, Ted
> >  * <http://www.StrutsMentor.com/>
> >
> > On Jan 7, 2008 2:36 PM, Wes Wannemacher <wesw@wantii.com> wrote:
> > > Hello,
> > >
> > > I have been struggling to find a way to see what the namespace is from
> > > within a JSP. So, from the view, I would like to know what the namespace
> > > is of the action that was called.
> > >
> > > The following scriptlet correctly returns the namespace -
> > > <%
> > > com.opensymphony.xwork2.ActionContext ac =
> > > com.opensymphony.xwork2.ActionContext.getContext();
> > > com.opensymphony.xwork2.ActionInvocation invo =
> > > ac.getActionInvocation();
> > > com.opensymphony.xwork2.ActionProxy proxy = invo.getProxy();
> > > out.println(proxy.getNamespace());
> > > %>
> > >
> > > But, if I use the following OGNL -
> > > <s:property
> > > value="@com.opensymphony.xwork2.ActionContext@getContext().actionInvocation.proxy.namespace"/>
> > >
> > > I just get a big fat nothing :(
> > >
> > > I am open to any suggestions, I just want to know what namespace is... I
> > > don't really want to parse the requested URL. If I can't figure it out
> > > in OGNL, I will probably write an interceptor to put the value somewhere
> > > that I can read it in OGNL. Before I write the interceptor through, I
> > > figured I would ask here since I might be doing something blatantly
> > > wrong.
> > >
> > > Thanks!
> > >
> > > -Wes

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message