Hi, Carlos,
Answers within. Please note that if you use the DispatchUtil solution, they you don't need the DispatchAction solution. I.e. you don't need to subclass DispatchAction if you use DispatchUtil. The different solutions on this page should be used independently. They are not complementary.
You don't need to do anything with struts-config.xml in any of these solutions. If you use DispatchUtil, you just put in the methods you want in your Action class as you indicate and then call DispatchUtil as indicated in your execute(...) or process(...) method of your Action class. If you use DispatchAction, then what you do is obvious. You do not need DispatchUtil and DispatchAction. They are separate solutions.
Carlos Cajina - Hotmail wrote:
Yes. What I am calling the DispatchAction class here was called the SimpleDispatchAction class. I will change that. Thanks.Good morning.
Thanks to Mr. McGrady for his suggestion. I think the persistent nature of the need to handle multiple (image) buttons in web applications is precisely what makes this problem so recurrent ;^) I've moved from the 'ImageButtonBeanManager Extension' approach and decided to try to get SOLUTION TWO up & running but I've ran into a few problems and thought that maybe you could spare some time to help me out.
Issue #1
-----------
- In the SOLUTON ONE: DispatchUtil Solution Code the 'log' variable
declaration is as follows: protected static Log log =
LogFactory.getLog(DispatchUtil.class);
- In the SOLUTION TWO: (new) DispatchAction Solution Code the 'log' variable
declaration is as follows: protected static Log log =
LogFactory.getLog(SimpleDispatchAction.class);
* My first question is: In the second 'log' variable declaration, Where does
SimpleDispatchAction.class comes from? Shouldn't it read
DispatchAction.class?
This looks good. I don't know why you have the hidden property there. That is not needed for the button.Issue #2 ----------- - I have a class that extends my (new) DispatchAction class. Within this class I have coded the methods that will perform the actions referenced by the <html:submit...> buttons in my forms, i.e. public ActionForward [ next | back | finish ] ( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ... } - In my JSP forms, every button is defined like this: <html:form action="/wizard"> <html:hidden property="page" value="[ 1 | 2 | 3... ]" />
<bean:message key="someField.label" /> <html:text property="someField" />
<html:submit property="back.dispatch"> <bean:message key="button.back" /> </html:submit>
<html:cancel> <bean:message key="button.cancel" /> </html:cancel>
<html:submit property="next.dispatch">
<bean:message key="button.next" />
</html:submit>
</html:form>
* My second question is kinda stupid: What's next? I mean, It seems like IIf you use SOLUTION ONE, then you don't need SOLUTION TWO. You also don't need to use struts-config.xml at all the way you are proceeding.
can use struts-config.xml to get things working MappingDispatchAction style
or LookupDispatchAction style, but since the (new) DispatchAction (aka
DispatchUtil) takes care of things transparently, What would be the next
step to implement SOLUTION TWO?
Issue #3This should read "ActionFoward forward = new DispatchUtil().dispatch(this,mapping,form,request,response);" and it goes in the execute method of your ActionClass. Some versions of Action use process and some use execute.
-----------
* I don't get what this means :^( [Section 3.1. Action Class Code to Use]
"In all the following tag uses, you use the Action class code in
execute(...) or process(...) as given directly below.
ActionForward = forward = new
DispatchUtil().dispatch(this,mapping,form,request,response);"
Again, any help would be greatly appreciated.
Hope this helped.
Have a nice day!
Regards,
Carlos
----- Original Message ----- From: "Michael McGrady" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Thursday, September 23, 2004 9:00 PM
Subject: Re: [HOW TO? ImageButtonBeanManager Extension]
documentation I understand that what I need to do is create my Action FlowCarlos,
This solution just adds weight (ImageButtonBean) on top of (DispatchAction) and combines what are the same solutions really. I would suggest you look at what might be improvements to this sort of suggestion at http://wiki.apache.org/struts/StrutsCatalogFiveMultipleButtonSolutions .
Amazing how oftent this comes up.
Michael McGrady
Carlos Cajina - Hotmail wrote:
Hi. I'm tryin' to add this Strust extension to my project and from the
using the SubmitButtonForwardDispatchAction, but after coding my Action Form
and Action classes and setting up struts-config.xml I keep getting this
error:
Looking for Action instance for class2004-09-23 19:10:08,062 DEBUG [org.apache.struts.action.RequestProcessor]
com.mitranosoft.struts.actions.SubmitButtonForwardDispatchAction
Creating new Action instance2004-09-23 19:10:08,062 DEBUG [org.apache.struts.action.RequestProcessor]
[com.mitranosoft.struts.actions.SubmitButtonForwardDispatchAction]2004-09-23 19:10:08,156 WARN
SubmitButtonForwardDispatchAction.execute(): Warning - Error encountered and
handled while attempting to locate ActionForward property-name=[ submit ] of
[EMAIL PROTECTED], for Request=[
[EMAIL PROTECTED]/webm/asiste
nte.do,contextPath=/webm,method=POST,queryString=<null>,sessionId=BDCA619715
A1B419D6785F9CAADC7185] ].
[com.mitranosoft.struts.util.DefaultActionForwardSelector]2004-09-23 19:10:08,156 DEBUG
DefaultActionForwardSelector.getActionForward(): Returning a default
ActionForward matching name=[ otherwise ]. ActionForward=[
[EMAIL PROTECTED],path=/index.js
p,redirect=false,contextRelative=false] ], ActionForm=[
[EMAIL PROTECTED] ], for Request=[
[EMAIL PROTECTED]/webm/asiste
nte.do,contextPath=/webm,method=POST,queryString=<null>,sessionId=BDCA619715
A1B419D6785F9CAADC7185] ]
[com.mitranosoft.struts.actions.SubmitButtonForwardDispatchAction]2004-09-23 19:10:08,156 WARN
SubmitButtonForwardDispatchAction.execute(): Warning - A default ActionForm
has been selected or created, ActionForward=[
[EMAIL PROTECTED],path=/index.js
p,redirect=false,contextRelative=false] ], because no property was found for
property-name=[ submit ] of [EMAIL PROTECTED], for
Request=[
[EMAIL PROTECTED]/webm/asiste
nte.do,contextPath=/webm,method=POST,queryString=<null>,sessionId=BDCA619715
A1B419D6785F9CAADC7185] ]
processForwardConfig(ForwardConfig[name=otherwise,path=/index.jsp,redirect=f2004-09-23 19:10:08,156 DEBUG [org.apache.struts.action.RequestProcessor]
alse])
'back', 'finish'- In each of JSP's I have this for my buttons except for <html:cancel>: <html:submit property="submit">
<bean:message key="button.XXXX" /> // Where XXXX could be 'next',
SubmitButtonForwardDispatchAction action- does the job of automatically</html:submit>
I understand that the extension -through the
mapping a <html:submit...> button to an Action that is supposed to process
the specific business logic that button encapsulates, acting like some kind
of hub for every incoming button click in the JSP forms, but I don't know
whether I am missing something because things just won't work.
SubmitButtonForwardDispatchAction for a 'cancel' action works fine, wheneverIt's worth saying that the mapping in the
I hit the cancel button in my form I'm redirected to the correct location;
also the 'otherwise' mapping works good... it's were I'm taken to everytime
I hit the next button and the errors pops up in the log files :^P
For any help, my eternal gratitude :^)
Have a nice evening.
Regards,
Carlos
--------------------------------------------------------------------- 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]