"Also, a request parameter, which would be visible to the application user, is not required to enable selection of the handler method."
Looked right at that and didn't see it!
Thanks again, Erik
Jim Barrows wrote:
-----Original Message----- From: Erik Weber [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 14, 2004 4:15 PM To: Struts Users Mailing List Subject: Re: Question concerning struts-config and app constants
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
Well.... from the javadocs for public class MappingDispatchAction: To configure the use of this action in your struts-config.xml file, create an entry like this:
<action path="/saveSubscription" type="org.example.SubscriptionAction" name="subscriptionForm" scope="request" input="/subscription.jsp" parameter="method"/> where 'method' is the name of a method in your subclass of MappingDispatchAction that has the same signature (other than method name) of the standard Action.execute method.
Nothing in the there about the URL.... so yes you could use it for what you want to. You can look at the javadocs yourself and see a better example of how it works.
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".http://struts.apache.org/api/org/apache/struts/actions/MappingDispatchAction.html
What do you think?
Thanks, Erik
Joe Germuska wrote:
attribute to the> I am parameterizing an Action via the "parameter"
the Action classaction element in struts-config.xml. The Java code in
constants insteadrefers to the possible parameter values using String
values areof using literal values. However, these same parameter
vice-versa. Issimply
hardcoded in struts-config.xml. So if I change the values of the
constants, I have to change struts-config.xml, and
conditionalIf 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 ofthere> an easy way to have the values for these constants in one place?
instead ofchecking:
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
as String constants and eliminate the need to test the parameter against the constant.
Joe
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]