I was thinking of loading a properties file for my KeyMethodMap in a
subclass of LookupDispatchAction.

So this:

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

        map.put("button.add", "add");
        map.put("button.cancel", "cancel");
        map.put("button.copy", "copy");
        map.put("button.save", "save");
        map.put("button.edit", "edit");

        return map;
    }

Could be replaced with the following psuedo code:

    protected Map getKeyMethodMap()
    {
        Map map = new HashMap();
        ResourceBundle methods = 
            ResourceBundle.getBundle("LookupMethods");

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

        return map;
    }


Is there any reason(s) why I shouldn't do this?  I think it allows
greater flexibility for development - so I don't have to re-compile this
class everytime I want map a new method.  My last project had 18
different mappings for the the different button names - where many
mapped to the same method.

Thanks,

Matt

Reply via email to