struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@Eng.Sun.COM>
Subject Re: Struts--question about bean/form name.
Date Wed, 21 Jun 2000 16:16:21 GMT
Kevin Duffey wrote:

> Hi,
>
> is there any way in each of my action perform() methods to get the "name" of
> the bean that was set in the action.xml, so that I can use that String name
> for various purposes? For example, we don't use EJB yet, so we separate our
> logic into "logic_session" classes. These session classes are stored in the
> HttpSession, with a reference to our bean, and I would like to store them by
> using the name of the bean (form passed in) and appending "Session" to that
> name. In the JSP page I have to hardcode it though..which means I still have
> to change the bean name in two places..if I change it for any reason.
>

The perform() method of an action receives a "mapping" parameter that is the
ActionMapping instance which caused this action to be invoked.  Therefore, you
can access any of the properties of that mapping -- for example, you can
retrieve the session key under which the form bean for this action is stored, by
calling

    mapping.getFormAttribute()

in your action class.  See the next response for how to extend this capability
with your own properties.

>
> Thanks.

Craig



Mime
View raw message