Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ImageButton with DispatchAction

 
Sidharth Pallai
Ranch Hand
Posts: 134
Hibernate Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Anirvan Majumdar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 134
Hibernate Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic