| Author |
MappingDispatchAction's JSP CODE
|
Tokunbo Oke
Ranch Hand
Joined: Sep 09, 2003
Posts: 57
|
|
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. JSP CODE ======== The works with DispatchAction. However, due to the limitations of DispatchAction, I want to use the new MappingDispatchAction class. <html:form action="/Customer"> <%-- onsubmit="return validateCargoForm(this);"--%> <table width="500" border="0"> ................ ................ other fields.... ................ ................ <html:hidden property="methodToExecute" value="unknownMethod"/> <SCRIPT>function set(target) {document.forms[0].methodToExecute.value=target;}</SCRIPT> <html:submit on click="bCancel=true; set('getCustomers')">Get Customer</html:submit> <html:submit on click= "set('updateCustomer')">Update Customer</html:submit> <html:cancel/> </html:form> 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.
|
 |
sreenath reddy
Ranch Hand
Joined: Sep 21, 2003
Posts: 415
|
|
Hi The action will be the same as what u give in ur <action path="". no need to pass anything here just the diff between Dispatchaction and mappingda is taht here u need not pass that parameters value in query string that u can directly write in conig files paramter attribute
|
 |
Sheldon Fernandes
Ranch Hand
Joined: Aug 18, 2004
Posts: 157
|
|
Since the form bean type is the same for both getCustomer and updateCustomer, you can put any one in the form action. Lets say you use "getCustomer". Your form would then look like this. Note the submit button for update, first updates the form's action to "updateCustomer". You could also leave the set ('getCustomer') call on click of the "Get Customer" button (I have removed that here). In that way, only your set() javascript function would change. Remove the hidden control, it is not required anymore. <html:hidden property="methodToExecute" value="unknownMethod"/> What do you want to do on the "Cancel" event? Sheldon Fernandes
|
 |
Tokunbo Oke
Ranch Hand
Joined: Sep 09, 2003
Posts: 57
|
|
Thanks for your suggestions. What you suggested is exactly is what I did and it works. Regarding the cancel button, I want all fields to be empty after the button is clicked. Your suggestion will be appreciated. Thank you. Ola.
|
 |
Sheldon Fernandes
Ranch Hand
Joined: Aug 18, 2004
Posts: 157
|
|
<html:reset> should do the trick OR you could directly use an html input control of type reset. <input type="reset" value="Reset" /> Sheldon Fernandes [ October 11, 2004: Message edited by: Sheldon Fernandes ]
|
 |
Tokunbo Oke
Ranch Hand
Joined: Sep 09, 2003
Posts: 57
|
|
Thanks a lot, this also worked. It was staring me in the face all the while. One final question: Is there a trigger in Javaranch that I can switch on, so that when I log in, all my postings and the ones that I have responded to will automitically come up? Regards. Ola.
|
 |
Tokunbo Oke
Ranch Hand
Joined: Sep 09, 2003
Posts: 57
|
|
I have just noticed that the reset button - HTML:RESET only clears unsubmitted data. It does not clear data retrieved from the database. Can you please shed some light on why this is the case? I am wondering if I have to add an on click event to the reset button that forward to a mapping-->class.method-->formBean that sets all the fields to null in the formBean. Thank you. Ola.
|
 |
 |
|
|
subject: MappingDispatchAction's JSP CODE
|
|
|