> I am parameterizing an Action via the "parameter" attribute to the
 action element in struts-config.xml. The Java code in the Action class
 refers to the possible parameter values using String constants instead
 of using literal values. However, these same parameter values are simply
 hardcoded in struts-config.xml. So if I change the values of the
 constants, I have to change struts-config.xml, and vice-versa. Is there
> an easy way to have the values for these constants in one place?

If you describe somewhat more what you're doing with the parameters inside the action, we might be able to suggest an alternative implementation. For example, if you're doing some kind of conditional checking:


 if (MY_CONSTANT1.equals(mapping.getParameter())) { ... }
else if (MY_CONSTANT2.equals(mapping.getParameter())) { ... }

you might instead be able to use the MappingDispatchAction, which would encode the Java side of your values as method names instead of as String constants and eliminate the need to test the parameter against the constant.

http://struts.apache.org/api/org/apache/struts/actions/MappingDispatchAction.html

Joe

--
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn back; I'll know I'm in the wrong place."
- Carlos Santana

Reply via email to