htmls:submit buttons and links in struts
Hello,
I am developing a struts web application. In the course of that I have two questions:
How can I define an image to display for a html:submit button instead the traditional visualization of the html:submit button?
The same for links - How can I define an image for a link?
thanks in advance
Kind Regards
pat
Struts provides a specific tag for the image submit buttons -
<html:image/>
as opposed to <html:img> (which just displays an image)
For links, just nest the image inside the anchor/link
<html:link ....><html:img ...></html:link>
You should be aware that the html:image button will never submit a value. It will only ever submit the x,y co-ordinates of where you clicked on the image button. You have to use javascript onclick events to set values manually if you want to distinguish which button was pressed via a value.
Hello,
thank you for your reply.
So it is not possible to use the html:image button in the same way as an traditional html:submit button to send the values in a html:form in a Form-Bean to an ActionClass...?:(
How do I have to modify the html:image button to use it in the same way as an traditional html:submit button in a html:form?
regards
pat
I'm sorry for the revival of this old thread, but I've encountered the same issue (more or less). (I stumbled upon this thread via Google).
I have a form with two buttons, reset and submit. I want to use images for the two buttons. Our first solution was to use <html:image /> tag, but the two buttons submit the form. So, we've changed our reset-button, and added some javascript to reset the form. Everything worked fine in Internet Explorer but Firefox seems to fire the first button on the form, when you press enter in a textfield. Is there a way to overcome this thing? We can't rearrange the order of the buttons, because we're migrating an existing UI.
This is my solution:
<html:link href="#" onclick="javascript:document.forms[0].reset(); return false;">
<html:img src="images/reset_form.gif" />
</html:link>
<html:image src="images/getuserinformation.gif" property="submit" />