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

[356 byte] By [patrick270881a] at [2007-10-2 6:25:01]
# 1

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.

evnafetsa at 2007-7-16 13:26:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

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

patrick270881a at 2007-7-16 13:26:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

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.

Bjorn-a at 2007-7-16 13:26:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Ok, I've resolved the issue by putting a html:img tag and wrapped an html:link-tag around it.
Bjorn-a at 2007-7-16 13:26:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
I actually had the same problem and solved it many different ways for different buttons. I'm not currently at work right now but will submit a solution when I do.For other people answering please submit your code examples and findings.
RealDeal44a at 2007-7-16 13:26:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

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" />

Bjorn-a at 2007-7-16 13:26:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...