Ooops, Rick! I made an error speeding on this. Let me work on it and
get back to you later.
Michael
Michael McGrady wrote:
Rick Reumann wrote:
Hey, yes that is pretty cool.
Hi, Rick,
Your notes on links confuse me a bit. Let me consider what confuses
me and then we can go from there.
FIRST
You said ". . . MappingDispatchAction has . . . a cetnralized place to
decide what method is called based on the action name." I understand
this to mean that a different method is called for different action
names. Is that right? That seems odd, since the
MappingDispatchAction is an action. So, if you called a different
MappingDispatchAction, you would, presumably, call a different action
but the same method name. Is this right? Did you mean to say that?
SECOND
You said "If I decide I want . . . links to go a different dispatch
method I simply change the parameter name in my struts-config for the
mapping for 'fooBar'". You are, I assume, thinking of the following
sort of case:
|<action path="/createSubscription"
type="org.example.SubscriptionAction"
parameter="create">
<forward name="success" path="/editSubscription.jsp"/>
</action>
<action path="/editSubscription"
type="org.example.SubscriptionAction"
parameter="edit">
<forward name="success" path="/editSubscription.jsp"/>
</action>
|
Suppose that SubscriptionAction is a SimpleDispatchAction subclass.
Just put a ".x" after the parameter names, and SimpleDispatchActions
do exactly the same thing as your MappingDispatchActions.
However, that just makes SimpleDispatchAction as powerful as
MappingDispatchAction, it is actually more powerful. What you have to
do is not advisable, I think. What you suggest doing is, I would
suggest, a very bad idea. You are thinking of changing the mapping so
that the following code <c:url var="url"
value="/editSubscription.do"/><a href="${url}">[ editSubscription]</a>
does something other than edit a subscription. This is not, I would
suggest, a good idea.
What normally you would want when you want a link to initiate a
different command/operation is to have the link exhibit that change on
the page. The beauty of SimpleDispatchAction is that you can do this
and change nothing else. (You also only have to have one action
mapping rather than the melange of mappings usually required by a
MappingDispatchAction.) If you want to create rather than edit a
subscription, in SimpleDispatchAction you go from:
<c:url var="url" value="/subscription.do?edit.x=edit"/><a
href="${url}">[ edit]</a>
to
<c:url var="url" value="/subscription.do?create.x=create"/><a
href="${url}">[ create]</a>
If you don't want to do this, you can use a variable for the value of
the url. I do that all the time. I hard code very, very little on a
page.
Does this answer make any sense to you?
Michael McGrady
||||
---------------------------------------------------------------------
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]