This looks reasonable. Generally speaking changing a button mapping would involve new code, so a recompile is necessary, but as you mention you are mapping multiple buttons to the same method.
Although I'd caution against using LookupDispatchAction unless you really have forms that have multiple submit buttons to submit that same form data. If you're simply mapping multiple non-form-related actions into one class, then I'd argue this is not the right approach.
Erik
p.s. It looks like you might be able to save a few lines of code by using the Properties.load method instead of going through a ResourceBundle. ???
Matt Raible wrote:
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
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
