Re: MappingDispatchAction's JSP code
O. Oke wrote the following on 9/24/2004 6:22 AM: I have a class that extends the new MappingDispatchAction class . This class has two methods, namely getCustomer and updateCustomer. The corresponding mapping for each method are below: action path=/getCustomer type=com.fujimitsu.cargo.gen.CustomerAction name=cargoForm scope=request validate=false input=.customerDef.jsp parameter=getCustomer forward name=success path=.customerDef.jsp / /action action path=/updateCustomer type=com.fujimitsu.cargo.gen.CustomerAction name=cargoForm scope=request validate=true input=.customerDef.jsp parameter=updateCustomer forward name=success path=.customerDef.jsp / /action my jsp has three buttons, namelygetCustomer, updateCustomer and cancel. JSP CODE The works with DispatchAction. However, due to the limitations of DispatchAction, I want to use the new MappingDispatchAction class. What are these limitations? For what you are trying to do the limitations are actually the other way around:) html:form action=/Customer %-- onsubmit=return validateCargoForm(this);--% table width=500 border=0 other fields html:hidden property=methodToExecute value=unknownMethod/ SCRIPTfunction set(target) {document.forms[0].methodToExecute.value=target;}/SCRIPT html:submit onclick=bCancel=true; set('getCustomers')Get Customer/html:submit html:submit onclick= set('updateCustomer')Update Customer/html:submit html:cancel/ /html:form Your trying to use a MappingDispatchAction like a DispatchAction don't do this. Just use DispatchAction. So you make one Action CustomerAction and you can have one mapping action path=/customerAction .. and then you have the different dispatch methods inside. Simple. If you want to use MappingDispatchAction then you'll have to use javascript to change the action name in your html:form action= section. I find that uglier than setting a dispatch parameter with javascript. I guess you didn't look at the SimpleDispatchAction either? -- Rick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: MappingDispatchAction's JSP code
I am not sure what you have in mind at this point. Do you still want to go on with MappingDispatchAction? Michael McGrady O. Oke wrote: Thanks for your response, I have rephrased my question as below: Please help! Background == I have a class that extends the new MappingDispatchAction class . This class has two methods, namely getCustomer and updateCustomer. The corresponding mapping for each method are below: action path=/getCustomer type=com.fujimitsu.cargo.gen.CustomerAction name=cargoForm scope=request validate=false input=.customerDef.jsp parameter=getCustomer forward name=success path=.customerDef.jsp / /action action path=/updateCustomer type=com.fujimitsu.cargo.gen.CustomerAction name=cargoForm scope=request validate=true input=.customerDef.jsp parameter=updateCustomer forward name=success path=.customerDef.jsp / /action my jsp has three buttons, namelygetCustomer, updateCustomer and cancel. My question: 1. In my JSP, what what should be the value of the ACTION attribute of html:form i.e. html:form action=?? (i.e. which mapping should be specified here)? 2. what should the code of the button for excuting a. getCustomer and updateCustomer method be? i.e. html:submit ??? b. cancel be i.e. html:cancel ??? Thank you. Thanks for your response, I have rephrased my question as above. --- Michael McGrady [EMAIL PROTECTED] wrote: If you would like a simpler, and more general, solution that does the same thing, try http://wiki.apache.org/struts/StrutsCatalogFiveMultipleButtonSolutions . However, if you like MappingDispatchAction anyway, which I would find odd but you may find even, you can do whatever you like, but you have to generate the correct path with your button or form. Michael O. Oke wrote: If it is /updateCustomer, it means I will have to a separate jsp for each mapping. This will defeat the purpose of using MappingDispatchAction. It seems to me that your suggestion is only applicable to subclasses of Action, not MappingDispatchAction . I am asking because I am using MappingDispatchAction for my project. Thank you. --- Hubert Rabago [EMAIL PROTECTED] wrote: 1. The action attribute of the form tag should point to the action that will process the form upon submission. In your case, it looks like it would be /updateCustomer, but I'm just guessing. 2. I usually just put html:submit value=Submit/ or Save or something similar there because I usually have only one submit button. If you're asking because you read something about this button mapped to that method, that's LookupDispatchAction. MappingDispatchAction is a lot easier to deal with when it comes to mapping methods, IMO. :) Hubert On Thu, 23 Sep 2004 15:26:56 +0100 (BST), O. Oke [EMAIL PROTECTED] wrote: Please help! I have a class that extends MappingDispatchAction class . This class has, they are below: action path=/getCustomer type=com.fujimitsu.cargo.gen.CustomerAction name=cargoForm scope=request validate=false input=.customerDef.jsp parameter=getCustomer forward name=success path=.customerDef.jsp / /action action path=/updateCustomer type=com.fujimitsu.cargo.gen.CustomerAction name=cargoForm scope=request validate=true input=.customerDef.jsp parameter=updateCustomer forward name=success path=.customerDef.jsp / /action My question: 1. In my JSP, what what should be the value of the action attribute of html:form i.e. html:form action=?? (i.e. which mapping should be specified here)? 2. what should the code of the button for excuting getCustomer method be? i.e. html:submit ??? Thank you. ___ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com - 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] ___ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com
Re: MappingDispatchAction's JSP code
O. Oke wrote the following on 9/23/2004 5:47 PM: Background == I have a class that extends the new MappingDispatchAction class . This class has two methods, namely getCustomer and updateCustomer. The corresponding mapping for each method are below: action path=/getCustomer type=com.fujimitsu.cargo.gen.CustomerAction name=cargoForm scope=request validate=false input=.customerDef.jsp parameter=getCustomer forward name=success path=.customerDef.jsp / /action action path=/updateCustomer type=com.fujimitsu.cargo.gen.CustomerAction name=cargoForm scope=request validate=true input=.customerDef.jsp parameter=updateCustomer forward name=success path=.customerDef.jsp / /action my jsp has three buttons, namelygetCustomer, updateCustomer and cancel. You sure you have a form that has a get customer and an update customer on the same page? That doesn't make too much sense. You sure get customer doesn't just take you to another page where you choose a customer to get? It sounds like you don't need to have a form to do what you want but probably just want a button that goes to a url mapped to your action. If they truly are buttons on a form then MappingDispatchAction is horrible for this. You end up having to swap out your action name with javascript which I don't like. Use any of the other dispatch flavors instead of MappingDispatch action for multiple buttons. Michael's SimpleDispatchAction handles this well or simply use a regular DispatchAction and change the dispatch parameter name with javascript. If you can't use javascript then use the SimpleDispatchAction over LookupDispatch action. I don't like the LookupDispatchAction at all. For a dispatch action you could do something similar to: html:hidden property=dispatch html:submit onclick=myForm.dispatch.value='update'Update/html:submit html:submit onclick=myForm.dispatch.value='get'Get Customer/html:submit Michael's SimpleDispatchAction is much cleaner though for multiple buttons on a page. You should give it a try. -- Rick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]