You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Cheshire <ch...@gmail.com> on 2006/02/20 19:21:32 UTC

init-param equivalent for action configuration?

If I am reading the docs right, the "parameter" attribute of the
action element only allows you to define 1 generic parameter for the
action.

I need to be able to specify a few different parameters and their
values. Prior to converting to struts I would put these as init-params
in web.xml under each servlet declaration.

Is there a way to do this in the struts config without using global
context params in web.xml?

Thanks

Chris

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


Re: init-param equivalent for action configuration?

Posted by Chris Cheshire <ch...@gmail.com>.
Thanks Laurie

On 2/20/06, Laurie Harper <la...@holoweb.net> wrote:
> Chris Cheshire wrote:
> > If I am reading the docs right, the "parameter" attribute of the
> > action element only allows you to define 1 generic parameter for the
> > action.
> >
> > I need to be able to specify a few different parameters and their
> > values. Prior to converting to struts I would put these as init-params
> > in web.xml under each servlet declaration.
> >
> > Is there a way to do this in the struts config without using global
> > context params in web.xml?
> >
> > Thanks
> >
> > Chris
>
> Is the <set-property> element what you're looking for?
>
>    <action ...>
>      <set-property property="myProperty" value="..."/>
>    </action>
>
> L.
>

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


Re: init-param equivalent for action configuration?

Posted by Chris Cheshire <ch...@gmail.com>.
OK I am still lost. I found reference to this in the DTD, so that
covers the config file.

However, I cannot find any mention of how to retrieve these properties
in the Action subclass. I took a look at the javadocs for Action,
ActionConfig, ActionMapping and I do not see anything relating to the
set-property element of the configuration file.

Are these translated by the struts framework into servlet context parameters?

Is there anything in the struts documentation that describes this?

Chris

On 2/20/06, Laurie Harper <la...@holoweb.net> wrote:
> Chris Cheshire wrote:
> > If I am reading the docs right, the "parameter" attribute of the
> > action element only allows you to define 1 generic parameter for the
> > action.
> >
> > I need to be able to specify a few different parameters and their
> > values. Prior to converting to struts I would put these as init-params
> > in web.xml under each servlet declaration.
> >
> > Is there a way to do this in the struts config without using global
> > context params in web.xml?
> >
> > Thanks
> >
> > Chris
>
> Is the <set-property> element what you're looking for?
>
>    <action ...>
>      <set-property property="myProperty" value="..."/>
>    </action>
>
> L.

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


Re: init-param equivalent for action configuration?

Posted by Chris Cheshire <ch...@gmail.com>.
After a lot of browsing javadocs and scratching my head in confusion,
I have something that appears to be working.

In struts-config.xml I have a few <set-property ...> elements for an
action. For the action mapping element of that action I have
className="my mapping class".

I have created a class that extends ActionMapping that provides get
and set methods for these properties.

These are then accessible inside the action by casting the provided
action to the right class.

Now that I have spent 2 hours looking at javadocs, I understand what
is going on (I hope!) but this could REALLY do with an entry in the
descriptive documentation. The javadocs only provide subtle hints
about what is going on with that particular class and nothing ties any
of it together.

Have I missed something? Do I need to do anything else?

Chris

On 2/20/06, Laurie Harper <la...@holoweb.net> wrote:
> Chris Cheshire wrote:
> > If I am reading the docs right, the "parameter" attribute of the
> > action element only allows you to define 1 generic parameter for the
> > action.
> >
> > I need to be able to specify a few different parameters and their
> > values. Prior to converting to struts I would put these as init-params
> > in web.xml under each servlet declaration.
> >
> > Is there a way to do this in the struts config without using global
> > context params in web.xml?
> >
> > Thanks
> >
> > Chris
>
> Is the <set-property> element what you're looking for?
>
>    <action ...>
>      <set-property property="myProperty" value="..."/>
>    </action>
>
> L.
>
>
> ---------------------------------------------------------------------
> 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: init-param equivalent for action configuration?

Posted by Laurie Harper <la...@holoweb.net>.
Chris Cheshire wrote:
> If I am reading the docs right, the "parameter" attribute of the
> action element only allows you to define 1 generic parameter for the
> action.
> 
> I need to be able to specify a few different parameters and their
> values. Prior to converting to struts I would put these as init-params
> in web.xml under each servlet declaration.
> 
> Is there a way to do this in the struts config without using global
> context params in web.xml?
> 
> Thanks
> 
> Chris

Is the <set-property> element what you're looking for?

   <action ...>
     <set-property property="myProperty" value="..."/>
   </action>

L.


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