You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brandon Goodin <ma...@phase.ws> on 2003/02/24 18:35:29 UTC

ActionMapping enhancement?

Do any of you face this issue? and how do you deal with it?

SCENARIO:
I have a set of classes that handle event calendars.

The same classes can be used within one site to maintain multiple event
calendars.

The event calendar contains multiple categories.

I want to utilize the event calendar from various urls to display specific
event calendars:

/do/ec/city - shows event calendar for city events
/do/ec/elksclub - shows event calendar for elks club
etc...

But I want to provide default parameters to each of the mappings so that the
event calendar action knows which event calendar to display without having
to pass it in through a query parameter.

In other words I want to handle the default parameters in the
struts-config.xml.

The only solutions both include extending the ActionMapping class and using
the set-property in the action-mapping of the struts-config.xml:

SOLUTIONS

1) Create a new module (Event Calendar module). Provide a custom extended
ActionMapping to handle properties that may be passed in for the classes
used under the module.

2) Extend the ActionMapping class and provide a setter/getter that receives
a comma delimited value ([0],[1];0=key 1=value) and stores it into a HashMap
in the extended ActionMapping class. I could then provide an accessor method
to retrieve a particular property in the hashmap (i.e. getValue(String
key)). I could then retrieve the value from the action mapping reference
within my action class to initialize default values based on the mapping of
the url.

Thoughts? Corrections?

REASONS:
Default parameters that are contained in a url querystring get difficult to
handle. It is nice to be able to change them in one place when needed. This
avoids having to pillage through every page that may contain a reference to
a partical url/querystring combo and adjust the parameters rather that just
one.
Also, if the action mapping could contain a hashmap of properties... one
could provide runtime configuration info to an Action class in order to
affect it's behavior a certain way. This promotes reusability of code.

Brandon Goodin
Phase Web and Multimedia
PO Box 85
Whitefish MT 59937
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws



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


RE: ActionMapping enhancement?

Posted by Brandon Goodin <ma...@phase.ws>.
interesting.

<set-property property="property(titleKey)" value="actionY.title"/>

I wasn't aware that property(xxx) notation could be used to populate and
retrieve map values within the struts-config.xml.

Brandon Goodin
Phase Web and Multimedia
PO Box 85
Whitefish MT 59937
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws


-----Original Message-----
From: Jerome Jacobsen [mailto:jerome.jacobsen@gentootech.com]
Sent: Monday, February 24, 2003 10:53 AM
To: Struts Users Mailing List
Subject: RE: ActionMapping enhancement?


Hi Brandon,

I just posted something on a different topic that may solve your problem.
Basically it is like your Solution #2, except it doesn't use a "comma
delimited value" getter/setter.  Not sure why you need that.  Anyway, here's
the posting URL.

http://shorl.com/dutydapedroho

-Jerome

> -----Original Message-----
> From: Brandon Goodin [mailto:mail@phase.ws]
> Sent: Monday, February 24, 2003 12:35 PM
> To: Struts User List
> Subject: ActionMapping enhancement?
>
>
> Do any of you face this issue? and how do you deal with it?
>
> SCENARIO:
> I have a set of classes that handle event calendars.
>
> The same classes can be used within one site to maintain multiple event
> calendars.
>
> The event calendar contains multiple categories.
>
> I want to utilize the event calendar from various urls to display specific
> event calendars:
>
> /do/ec/city - shows event calendar for city events
> /do/ec/elksclub - shows event calendar for elks club
> etc...
>
> But I want to provide default parameters to each of the mappings
> so that the
> event calendar action knows which event calendar to display without having
> to pass it in through a query parameter.
>
> In other words I want to handle the default parameters in the
> struts-config.xml.
>
> The only solutions both include extending the ActionMapping class
> and using
> the set-property in the action-mapping of the struts-config.xml:
>
> SOLUTIONS
>
> 1) Create a new module (Event Calendar module). Provide a custom extended
> ActionMapping to handle properties that may be passed in for the classes
> used under the module.
>
> 2) Extend the ActionMapping class and provide a setter/getter
> that receives
> a comma delimited value ([0],[1];0=key 1=value) and stores it
> into a HashMap
> in the extended ActionMapping class. I could then provide an
> accessor method
> to retrieve a particular property in the hashmap (i.e. getValue(String
> key)). I could then retrieve the value from the action mapping reference
> within my action class to initialize default values based on the
> mapping of
> the url.
>
> Thoughts? Corrections?
>
> REASONS:
> Default parameters that are contained in a url querystring get
> difficult to
> handle. It is nice to be able to change them in one place when
> needed. This
> avoids having to pillage through every page that may contain a
> reference to
> a partical url/querystring combo and adjust the parameters rather
> that just
> one.
> Also, if the action mapping could contain a hashmap of properties... one
> could provide runtime configuration info to an Action class in order to
> affect it's behavior a certain way. This promotes reusability of code.
>
> Brandon Goodin
> Phase Web and Multimedia
> PO Box 85
> Whitefish MT 59937
> P (406) 862-2245
> F (406) 862-0354
> mail@phase.ws
> http://www.phase.ws
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>


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



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


RE: ActionMapping enhancement?

Posted by Jerome Jacobsen <je...@gentootech.com>.
Hi Brandon,

I just posted something on a different topic that may solve your problem.
Basically it is like your Solution #2, except it doesn't use a "comma
delimited value" getter/setter.  Not sure why you need that.  Anyway, here's
the posting URL.

http://shorl.com/dutydapedroho

-Jerome

> -----Original Message-----
> From: Brandon Goodin [mailto:mail@phase.ws]
> Sent: Monday, February 24, 2003 12:35 PM
> To: Struts User List
> Subject: ActionMapping enhancement?
>
>
> Do any of you face this issue? and how do you deal with it?
>
> SCENARIO:
> I have a set of classes that handle event calendars.
>
> The same classes can be used within one site to maintain multiple event
> calendars.
>
> The event calendar contains multiple categories.
>
> I want to utilize the event calendar from various urls to display specific
> event calendars:
>
> /do/ec/city - shows event calendar for city events
> /do/ec/elksclub - shows event calendar for elks club
> etc...
>
> But I want to provide default parameters to each of the mappings
> so that the
> event calendar action knows which event calendar to display without having
> to pass it in through a query parameter.
>
> In other words I want to handle the default parameters in the
> struts-config.xml.
>
> The only solutions both include extending the ActionMapping class
> and using
> the set-property in the action-mapping of the struts-config.xml:
>
> SOLUTIONS
>
> 1) Create a new module (Event Calendar module). Provide a custom extended
> ActionMapping to handle properties that may be passed in for the classes
> used under the module.
>
> 2) Extend the ActionMapping class and provide a setter/getter
> that receives
> a comma delimited value ([0],[1];0=key 1=value) and stores it
> into a HashMap
> in the extended ActionMapping class. I could then provide an
> accessor method
> to retrieve a particular property in the hashmap (i.e. getValue(String
> key)). I could then retrieve the value from the action mapping reference
> within my action class to initialize default values based on the
> mapping of
> the url.
>
> Thoughts? Corrections?
>
> REASONS:
> Default parameters that are contained in a url querystring get
> difficult to
> handle. It is nice to be able to change them in one place when
> needed. This
> avoids having to pillage through every page that may contain a
> reference to
> a partical url/querystring combo and adjust the parameters rather
> that just
> one.
> Also, if the action mapping could contain a hashmap of properties... one
> could provide runtime configuration info to an Action class in order to
> affect it's behavior a certain way. This promotes reusability of code.
>
> Brandon Goodin
> Phase Web and Multimedia
> PO Box 85
> Whitefish MT 59937
> P (406) 862-2245
> F (406) 862-0354
> mail@phase.ws
> http://www.phase.ws
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>


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


RE: ActionMapping enhancement?

Posted by Brandon Goodin <ma...@phase.ws>.
Great.

Question:
I don't want to write an action-mapping class that has properties for my
event calendar action classes being used for my content management action
classes. That is the problem that I see. One ActionMapping class for all
your actions in the struts-config.xml. I like the idea of the hashmap so
that I can access dynamic/configurable properties from a common place in all
my action classes. But, at the same time I don't fill up my action mapping
class with a bunch of unneccessary getter/setters that don't apply to all my
action classes.

Brandon Goodin
Phase Web and Multimedia
PO Box 85
Whitefish MT 59937
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws


-----Original Message-----
From: Robert Taylor [mailto:rtaylor@mulework.com]
Sent: Monday, February 24, 2003 10:51 AM
To: Struts Users Mailing List
Subject: RE: ActionMapping enhancement?


Brandon,

I have a similar situation and I ended up extending ActionMapping
and using the set-property in the action-mapping in the struts-config file.


robert

> -----Original Message-----
> From: Brandon Goodin [mailto:mail@phase.ws]
> Sent: Monday, February 24, 2003 12:35 PM
> To: Struts User List
> Subject: ActionMapping enhancement?
>
>
> Do any of you face this issue? and how do you deal with it?
>
> SCENARIO:
> I have a set of classes that handle event calendars.
>
> The same classes can be used within one site to maintain multiple event
> calendars.
>
> The event calendar contains multiple categories.
>
> I want to utilize the event calendar from various urls to display specific
> event calendars:
>
> /do/ec/city - shows event calendar for city events
> /do/ec/elksclub - shows event calendar for elks club
> etc...
>
> But I want to provide default parameters to each of the mappings
> so that the
> event calendar action knows which event calendar to display without having
> to pass it in through a query parameter.
>
> In other words I want to handle the default parameters in the
> struts-config.xml.
>
> The only solutions both include extending the ActionMapping class
> and using
> the set-property in the action-mapping of the struts-config.xml:
>
> SOLUTIONS
>
> 1) Create a new module (Event Calendar module). Provide a custom extended
> ActionMapping to handle properties that may be passed in for the classes
> used under the module.
>
> 2) Extend the ActionMapping class and provide a setter/getter
> that receives
> a comma delimited value ([0],[1];0=key 1=value) and stores it
> into a HashMap
> in the extended ActionMapping class. I could then provide an
> accessor method
> to retrieve a particular property in the hashmap (i.e. getValue(String
> key)). I could then retrieve the value from the action mapping reference
> within my action class to initialize default values based on the
> mapping of
> the url.
>
> Thoughts? Corrections?
>
> REASONS:
> Default parameters that are contained in a url querystring get
> difficult to
> handle. It is nice to be able to change them in one place when
> needed. This
> avoids having to pillage through every page that may contain a
> reference to
> a partical url/querystring combo and adjust the parameters rather
> that just
> one.
> Also, if the action mapping could contain a hashmap of properties... one
> could provide runtime configuration info to an Action class in order to
> affect it's behavior a certain way. This promotes reusability of code.
>
> Brandon Goodin
> Phase Web and Multimedia
> PO Box 85
> Whitefish MT 59937
> P (406) 862-2245
> F (406) 862-0354
> mail@phase.ws
> http://www.phase.ws
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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



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


RE: ActionMapping enhancement?

Posted by Robert Taylor <rt...@mulework.com>.
Brandon,

I have a similar situation and I ended up extending ActionMapping
and using the set-property in the action-mapping in the struts-config file.


robert

> -----Original Message-----
> From: Brandon Goodin [mailto:mail@phase.ws]
> Sent: Monday, February 24, 2003 12:35 PM
> To: Struts User List
> Subject: ActionMapping enhancement?
>
>
> Do any of you face this issue? and how do you deal with it?
>
> SCENARIO:
> I have a set of classes that handle event calendars.
>
> The same classes can be used within one site to maintain multiple event
> calendars.
>
> The event calendar contains multiple categories.
>
> I want to utilize the event calendar from various urls to display specific
> event calendars:
>
> /do/ec/city - shows event calendar for city events
> /do/ec/elksclub - shows event calendar for elks club
> etc...
>
> But I want to provide default parameters to each of the mappings
> so that the
> event calendar action knows which event calendar to display without having
> to pass it in through a query parameter.
>
> In other words I want to handle the default parameters in the
> struts-config.xml.
>
> The only solutions both include extending the ActionMapping class
> and using
> the set-property in the action-mapping of the struts-config.xml:
>
> SOLUTIONS
>
> 1) Create a new module (Event Calendar module). Provide a custom extended
> ActionMapping to handle properties that may be passed in for the classes
> used under the module.
>
> 2) Extend the ActionMapping class and provide a setter/getter
> that receives
> a comma delimited value ([0],[1];0=key 1=value) and stores it
> into a HashMap
> in the extended ActionMapping class. I could then provide an
> accessor method
> to retrieve a particular property in the hashmap (i.e. getValue(String
> key)). I could then retrieve the value from the action mapping reference
> within my action class to initialize default values based on the
> mapping of
> the url.
>
> Thoughts? Corrections?
>
> REASONS:
> Default parameters that are contained in a url querystring get
> difficult to
> handle. It is nice to be able to change them in one place when
> needed. This
> avoids having to pillage through every page that may contain a
> reference to
> a partical url/querystring combo and adjust the parameters rather
> that just
> one.
> Also, if the action mapping could contain a hashmap of properties... one
> could provide runtime configuration info to an Action class in order to
> affect it's behavior a certain way. This promotes reusability of code.
>
> Brandon Goodin
> Phase Web and Multimedia
> PO Box 85
> Whitefish MT 59937
> P (406) 862-2245
> F (406) 862-0354
> mail@phase.ws
> http://www.phase.ws
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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