| Author |
ImageButton with DispatchAction
|
Sidharth Pallai
Ranch Hand
Joined: Apr 21, 2008
Posts: 134
|
|
How to use an image as a submit button in struts to invoke a dispatch action.When i use a image as button it get transfered as co-ordinates which create error in dispatching to specific methods. For eg. <form action="logaction"> <input type="image" name="login" value"log" src="Images/log.jpg"/> </form> It gets submitted as http://locahost/myapp/logaction?name.x=12&name.y=29 which gives error.Please assist to correct it.
|
Thanks & Regards
Sidharth Pallai
|
 |
Anirvan Majumdar
Ranch Hand
Joined: Feb 22, 2005
Posts: 261
|
|
You could use the <img> tag between <a> tags to have the same effect, and also, it has worked without any troubles to this date. [ April 28, 2008: Message edited by: Anirvan Majumdar ]
|
 |
Sidharth Pallai
Ranch Hand
Joined: Apr 21, 2008
Posts: 134
|
|
Originally posted by Anirvan Majumdar: You could use the <img> tag between <a> tags to have the same effect, and also, it has worked without any troubles to this date. [ April 28, 2008: Message edited by: Anirvan Majumdar ]
Thank you Anirban for your response.What i want actually is i need to pass a request parameter named="method" and value="add" along with other request parameters to dispatch action.I have configured the action in this way. I need a image which would act as button and would invoke dispatch action with a request parameter along with other parameters.My problem get solved when i replace the image with normal button which i dont need.
|
 |
Anirvan Majumdar
Ranch Hand
Joined: Feb 22, 2005
Posts: 261
|
|
I don't see what could cause a problem if you specify the URL to access on click of the image through the "href" attribute of the <a> tag. This would direct the control to the method "add" in the action class mapped to the "logaction" action-mapping. On the other hand, if you also want to access other values of the JSPs form, then you'll have to submit the form using some JavaScript code. For that, you can have something like: and your JS function could have the following structure:
|
 |
 |
|
|
subject: ImageButton with DispatchAction
|
|
|