You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Lirian Ostrovica <li...@senecac.on.ca> on 2002/12/29 20:09:53 UTC

How to get a reference to an Action instance

Hi,

I need to access an Action instance (I have its class name) while
writting a Tag.

I have seen that ActionServlet stores Action instances in a 'protected'
variable (FastHashMap), and so far the only way I can see, is to extend
ActionServlet and write my own 'public' method to do the job.
But of course I do not prefer to extend ActionServlet just for that...

If there is any other way, can someone please let me know

thanks a lot

lirian


> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to get a reference to an Action instance

Posted by Eddie Bush <ek...@swbell.net>.
Why do you want to do this?  I can't imagine why you would need to.

Lirian Ostrovica wrote:

>Hi,
>
>I need to access an Action instance (I have its class name) while
>writting a Tag.
>
>I have seen that ActionServlet stores Action instances in a 'protected'
>variable (FastHashMap), and so far the only way I can see, is to extend
>ActionServlet and write my own 'public' method to do the job.
>But of course I do not prefer to extend ActionServlet just for that...
>
>If there is any other way, can someone please let me know
>
>thanks a lot
>
>lirian
>
-- 
Eddie Bush




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to get a reference to an Action instance

Posted by Taylor Cowan <t....@charter.net>.
Action instances, like servlets, usually do not maintain state by using
member variables.  Thus most invokations of their methods do not depend upon
a particular instance, so you may just instantiate the action and invoke its
methods.  Of course, using the pooled instances maintained by struts would
be better performance wise.

Taylor

----- Original Message -----
From: "Lirian Ostrovica" <li...@senecac.on.ca>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Sunday, December 29, 2002 11:09 AM
Subject: How to get a reference to an Action instance


> Hi,
>
> I need to access an Action instance (I have its class name) while
> writting a Tag.
>
> I have seen that ActionServlet stores Action instances in a 'protected'
> variable (FastHashMap), and so far the only way I can see, is to extend
> ActionServlet and write my own 'public' method to do the job.
> But of course I do not prefer to extend ActionServlet just for that...
>
> If there is any other way, can someone please let me know
>
> thanks a lot
>
> lirian
>
>
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to get a reference to an Action instance

Posted by Kris Schneider <kr...@dotech.com>.
As others have said, it's unclear exactly what it is you need to do, but here's
a general suggestion for having a tag handler and action play nicely together -
use scoped attributes. In other words, if your tag handler needs some
information from your action, have the action place the information in a request
(or session or application) attribute that the handler can access through its
current PageContext. Of course, this implies that the action operates on the
request before the JSP...

Quoting Martin Cooper <ma...@apache.org>:

> On Sun, 29 Dec 2002, Lirian Ostrovica wrote:
> 
> > Hi,
> >
> > I need to access an Action instance (I have its class name) while
> > writting a Tag.
> >
> > I have seen that ActionServlet stores Action instances in a 'protected'
> > variable (FastHashMap), and so far the only way I can see, is to extend
> > ActionServlet and write my own 'public' method to do the job.
> > But of course I do not prefer to extend ActionServlet just for that...
> 
> Even if you know the class name, there is no guarantee that an instance of
> that Action exists, since Action instances are created as needed. And even
> if an instance does exist, what would be the purpose of accessing it? An
> Action instance should not maintain state, since that will cause threading
> problems, and if you need to access class data, then you do not need an
> instance.
> 
> Perhaps if you tell us what you are trying to achieve, we can help you
> find the right way to do that.
> 
> --
> Martin Cooper
> 
> 
> >
> > If there is any other way, can someone please let me know
> >
> > thanks a lot
> >
> > lirian
> >
> >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to get a reference to an Action instance

Posted by Martin Cooper <ma...@apache.org>.

On Sun, 29 Dec 2002, Lirian Ostrovica wrote:

> Hi,
>
> I need to access an Action instance (I have its class name) while
> writting a Tag.
>
> I have seen that ActionServlet stores Action instances in a 'protected'
> variable (FastHashMap), and so far the only way I can see, is to extend
> ActionServlet and write my own 'public' method to do the job.
> But of course I do not prefer to extend ActionServlet just for that...

Even if you know the class name, there is no guarantee that an instance of
that Action exists, since Action instances are created as needed. And even
if an instance does exist, what would be the purpose of accessing it? An
Action instance should not maintain state, since that will cause threading
problems, and if you need to access class data, then you do not need an
instance.

Perhaps if you tell us what you are trying to achieve, we can help you
find the right way to do that.

--
Martin Cooper


>
> If there is any other way, can someone please let me know
>
> thanks a lot
>
> lirian
>
>
> >
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>