You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Smith <de...@gmail.com> on 2008/06/24 12:39:33 UTC

Interceptor to access session objects

Hello,

Which interceptor can I use to access session objects by putting them
as paramteres in struts.xml?

Many thanks,
J

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


Re: Interceptor to access session objects

Posted by Ralf Fischer <th...@googlemail.com>.
Well, then I'd just use the ScopeInterceptor [1] to transfer arbitraty
action properties from one action to another via the session. Works
like a charm.

Cheers,
-Ralf

[1] http://struts.apache.org/2.1.2/struts2-core/apidocs/org/apache/struts2/interceptor/ScopeInterceptor.html

On Tue, Jun 24, 2008 at 4:39 PM, Lukasz Lenart
<lu...@googlemail.com> wrote:
>> You could try using an OGNL expression that references #session (like ${#session.foo}) but I don't know if that'll work. After trying it, it'd be nice if you reported back and/or added it to wiki (if it worked).
>
> It will not work, I've been trying. There is a bug in
> StaticParametersInterceptor, it will try to first put param on stack
> (and for above example, it will throw an exception) and then it will
> try to parse it.
>
>
> Regards
> --
> Lukasz
> http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: Interceptor to access session objects

Posted by Lukasz Lenart <lu...@googlemail.com>.
> You could try using an OGNL expression that references #session (like ${#session.foo}) but I don't know if that'll work. After trying it, it'd be nice if you reported back and/or added it to wiki (if it worked).

It will not work, I've been trying. There is a bug in
StaticParametersInterceptor, it will try to first put param on stack
(and for above example, it will throw an exception) and then it will
try to parse it.


Regards
-- 
Lukasz
http://www.lenart.org.pl/

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


Re: Interceptor to access session objects

Posted by Lukasz Lenart <lu...@googlemail.com>.
I think, the best solution for you is just to write your own
interceptor that will do what you want and applicable interface.


Regards
-- 
Lukasz
http://www.lenart.org.pl/

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


Re: Interceptor to access session objects

Posted by ChitraS <cs...@impetus.co.in>.
Dave, ${#session.foo} works in struts.xml.


newton.dave wrote:
> 
> --- On Tue, 6/24/08, John Smith <de...@gmail.com> wrote:
>> I like it to be automatically set, using the getter/setter
>> methods in the action. Can this be done with either 
>> SessionAware or through ActionContext?
> 
> No. ScopedModelDriven, IIRC, will also only retrieve the "model" property; 
> don't think it'll do arbitrary properties (could be wrong on that one,
> though).
> 
> You could try using an OGNL expression that references #session (like
> ${#session.foo}) but I don't know if that'll work. After trying it, it'd
> be nice if you reported back and/or added it to wiki (if it worked).
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Interceptor-to-access-session-objects-tp18088366p30549666.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Interceptor to access session objects

Posted by Dave Newton <ne...@yahoo.com>.
--- On Tue, 6/24/08, John Smith <de...@gmail.com> wrote:
> I like it to be automatically set, using the getter/setter
> methods in the action. Can this be done with either 
> SessionAware or through ActionContext?

No. ScopedModelDriven, IIRC, will also only retrieve the "model" property;  don't think it'll do arbitrary properties (could be wrong on that one, though).

You could try using an OGNL expression that references #session (like ${#session.foo}) but I don't know if that'll work. After trying it, it'd be nice if you reported back and/or added it to wiki (if it worked).

Dave


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


Re: Interceptor to access session objects

Posted by John Smith <de...@gmail.com>.
On Tue, Jun 24, 2008 at 2:18 PM, Dave Newton <ne...@yahoo.com> wrote:
> --- On Tue, 6/24/08, John Smith <de...@gmail.com> wrote:
>> Basically I add objectXYZ to the session in actionA then
>> the user submits a query to ActionB. I want to retrieve
>> objectXYZ from the session without directly calling the
>> a method on the session object inside actionB in order
>> to retrieve objectXYZ.
>
> I found the last sentence difficult to parse.
>
> What's your objection to ActionB retrieving the object via SessionAware (or through ActionContext)?

Well, an object from the session is to be retrieved from an action,
but I don't want to explicitly request the object from within the
action. I like it to be automatically set, using the getter/setter
methods in the action.

Can this be done with either SessionAware or through ActionContext?

Thanks,
J

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

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


Re: Interceptor to access session objects

Posted by John Smith <de...@gmail.com>.
I had a look at ScopedModelDrivenInterceptor but I didn't managed to
get it to work .There isn't much documentation on it or any examples
how the params are passed in the action :(

On Tue, Jun 24, 2008 at 1:41 PM,  <st...@gmail.com> wrote:
> Take a look at the Scoped Model Driven
> Interceptor<http://struts.apache.org/2.x/docs/scoped-model-driven-interceptor.html>
>
> Scott
>
> On Tue, Jun 24, 2008 at 6:32 AM, John Smith <de...@gmail.com> wrote:
>
>> On Tue, Jun 24, 2008 at 1:12 PM, Dave Newton <ne...@yahoo.com>
>> wrote:
>> > --- On Tue, 6/24/08, John Smith <de...@gmail.com> wrote:
>> >> Which interceptor can I use to access session objects by
>> >> putting them as parameters in struts.xml?
>> >
>> > What, specifically, are you trying to accomplish?
>>
>> Basically I add objectXYZ to the session in actionA then the user
>> submits a query to ActionB. I want to retrieve objectXYZ from the
>> session without directly calling the a method on the session object
>> inside actionB in order to retrieve objectXYZ.
>>
>> I looked at staticParameters and I can retrieve static param strings
>> set in struts.xml by only having getter and setter methods in an
>> action so I wanted to do something similar with dynamicly created
>> objects and referencing them in struts.xml
>>
>>
>> > Dave
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> --
> Scott
> stanlick@gmail.com
>

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


Re: Interceptor to access session objects

Posted by st...@gmail.com.
Take a look at the Scoped Model Driven
Interceptor<http://struts.apache.org/2.x/docs/scoped-model-driven-interceptor.html>

Scott

On Tue, Jun 24, 2008 at 6:32 AM, John Smith <de...@gmail.com> wrote:

> On Tue, Jun 24, 2008 at 1:12 PM, Dave Newton <ne...@yahoo.com>
> wrote:
> > --- On Tue, 6/24/08, John Smith <de...@gmail.com> wrote:
> >> Which interceptor can I use to access session objects by
> >> putting them as parameters in struts.xml?
> >
> > What, specifically, are you trying to accomplish?
>
> Basically I add objectXYZ to the session in actionA then the user
> submits a query to ActionB. I want to retrieve objectXYZ from the
> session without directly calling the a method on the session object
> inside actionB in order to retrieve objectXYZ.
>
> I looked at staticParameters and I can retrieve static param strings
> set in struts.xml by only having getter and setter methods in an
> action so I wanted to do something similar with dynamicly created
> objects and referencing them in struts.xml
>
>
> > Dave
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Scott
stanlick@gmail.com

Re: Interceptor to access session objects

Posted by Dave Newton <ne...@yahoo.com>.
--- On Tue, 6/24/08, John Smith <de...@gmail.com> wrote:
> Basically I add objectXYZ to the session in actionA then
> the user submits a query to ActionB. I want to retrieve 
> objectXYZ from the session without directly calling the 
> a method on the session object inside actionB in order 
> to retrieve objectXYZ.

I found the last sentence difficult to parse.

What's your objection to ActionB retrieving the object via SessionAware (or through ActionContext)?

Dave


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


Re: Interceptor to access session objects

Posted by John Smith <de...@gmail.com>.
On Tue, Jun 24, 2008 at 1:12 PM, Dave Newton <ne...@yahoo.com> wrote:
> --- On Tue, 6/24/08, John Smith <de...@gmail.com> wrote:
>> Which interceptor can I use to access session objects by
>> putting them as parameters in struts.xml?
>
> What, specifically, are you trying to accomplish?

Basically I add objectXYZ to the session in actionA then the user
submits a query to ActionB. I want to retrieve objectXYZ from the
session without directly calling the a method on the session object
inside actionB in order to retrieve objectXYZ.

I looked at staticParameters and I can retrieve static param strings
set in struts.xml by only having getter and setter methods in an
action so I wanted to do something similar with dynamicly created
objects and referencing them in struts.xml


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

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


Re: Interceptor to access session objects

Posted by Dave Newton <ne...@yahoo.com>.
--- On Tue, 6/24/08, John Smith <de...@gmail.com> wrote:
> Which interceptor can I use to access session objects by
> putting them as parameters in struts.xml?

What, specifically, are you trying to accomplish?

Dave


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