Thanks Joe, that is indeed what I am doing. I am handling a few actions
in a single Action class, but parameterizing on my own rather than using
the MappingDispatchAction. The reason is that the O'Reilly Struts book
led me to believe that if you want to use the DispatchAction class, or
the LookupDispatchAction class, you have to put the "method" parameter
into your requests. Please correct me if that is wrong. But I don't like
that. Is the MappingDispatchAction different from those (my book doesn't
seem to cover it)? I prefer to use a switch (the if-else block you
describe), to the chagrin of the OO purists, if it means I can keep the
URLs the user sees looking the way I want (I never much liked query
strings). My Action classes are not so course-grained as to become error
prone -- my parameter values are the likes of "add", "update" and "delete".
What do you think?
Thanks,
Erik
Joe Germuska wrote:
> 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
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]