You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Chen, Gin" <Gi...@NielsenMedia.com> on 2003/09/30 22:05:13 UTC

RE: externalizing the button hashmap for the LookupDispatchAction ?

But if your adding a new button then you will have to add the new code for
it anyways.
So would this help? If it was something that would allow you to not have to
redeploy then it might make sense but really we are just talking about one
more line of code ;)

-Tim

-----Original Message-----
From: Matt Raible [mailto:MRaible@RESORTQUEST.com] 
Sent: Tuesday, September 30, 2003 3:42 PM
To: 'Struts Users Mailing List'
Subject: RE: externalizing the button hashmap for the LookupDispatchAction ?


I've done it with a LookupMethods.properties file that contains the
following:

button.add=add
button.cancel=cancel
button.copy=copy
button.edit=edit
button.delete=delete
button.save=save
button.search=search

Then I have the following method in my BaseAction class:

    /**
     * Provides the mapping from resource key to method name
     *
     * @return Resource key / method name map
     */
    public Map getKeyMethodMap() {
        Map map = new HashMap();

        ResourceBundle methods =
 
ResourceBundle.getBundle("org.appfuse.webapp.action.LookupMethods");

        Enumeration keys = methods.getKeys();

        while (keys.hasMoreElements()) {
            String key = (String) keys.nextElement();
            map.put(key, methods.getString(key));
        }

        return map;
    }

It's not much better, but it does make it a *bit* easier to manage.

HTH,

Matt

-----Original Message-----
From: Mick Knutson [mailto:mickknutson@hotmail.com]
Sent: Tuesday, September 30, 2003 1:37 PM
To: struts
Subject: externalizing the button hashmap for the LookupDispatchAction?


I am just wondering if anyone has already made a nicer way to manage the
hashmap for the button labels on the LookupDispatchAction?
I hate having to continually add elements in the code when I add a new
button.

---
Thanks
Mick Knutson

coming soon:
Your SOS: Your personal emergency contact system.
http://YourSoS.com

+001(805) 563-0666 Office
+001 (708) 570-2772 Fax
---

---------------------------------------------------------------------
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