I'm not sure what you're referring to with a gray button with an image on
top of it.  What we use in our app, without worrying about using a struts
tag to get it, is the HTML:

<input type="image" name="done" src="/images/btns/save.gif" alt="Save"
width="52" height="20" border="0">

This is supported HTML (as of some version, but I believe it's supported by
all "modern" browsers) and simply does what you want, displays an image and
clicking on it does a submit of the form.

I believe <html:image> (not <html:img>) is supposed to generate an <input
type="image"> tag, but, unfortunately, it does a very buggy job of it (yes,
I plan on submitting the bugs).  I thought I could just shift to the
following tag:

<html:image property="done" src="/images/btns/save.gif" alt="Save"
width="52" height="20" border="0"/>

Turns out, the <html:image> tag doesn't even support width or height (BUG
1).  I think that's a mistake (unless it were to generate them
automatically) because these tend to help the browser display faster (I
think).  Also, the tag is documented as having a border attribute, but it
isn't defined in the tld file and so you get a complaint if you try to
specify one (BUG 2)!

Anyway, I ended up trying the tag (just removing height, width and border):

<html:image property="done" src="/images/btns/save.gif" alt="Save"/>

And the <input> tag it generated was screwed up (BUG 3)!  This is what I
got:

<input type="image" name="done src="/images/btns/save.gif" alt="Save">

Notice the missing closing double quote after "done".

However, to the original question, I believe that you can and should just
use an <input type="image"> tag as I've done above, or Kyle's JavaScript
version, if you prefer, as either should work fine in a form generated using
<html:form>.  The only thing you're missing out on, I think, is the ability
to have the URL for the image come from a message properties file, which
would aid in localization of the button.  However, perhaps the <html:image>
tag will be fixed by 1.0 ;-) and also you could probably implement that
yourself using the <bean:message> tag to retrieve the "message" which was
actually the image URL.

Have fun...off to bugzilla for me.  ;-)

Scott


> -----Original Message-----
> From: Kyle Robinson [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 25, 2001 4:33 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: How can I use a Image as a submit button using struts 
> 
> 
> That will make a gray button with the image on top of it.  I 
> think that
> looks ugly.  The version I use makes only the image the 
> button so you can
> make your web apps look alot nicer.
> 
> -----Original Message-----
> From: Scott Cressler [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 25, 2001 16:08
> To: '[EMAIL PROTECTED]'
> Subject: RE: How can I use a Image as a submit button using struts 
> 
> 
> Um, I thought the <html:image> tag did this and doesn't it generate an
> <input type="image"> tag?
> 
> Scott
> 
> > -----Original Message-----
> > From: Kyle Robinson [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, April 25, 2001 4:00 PM
> > To: '[EMAIL PROTECTED]'
> > Subject: RE: How can I use a Image as a submit button using struts 
> > 
> > 
> > The best way I've found of doing this is with a little javascript as
> > follows:
> > 
> > <a href="javascript:submit();">
> >     <img src="images/buttons/save.gif" name="save" border="0">
> > </a>
> > 
> > For the purposes of using Struts we made a custom tag to 
> > create these...
> > 
> > -----Original Message-----
> > From: Natra, Uday [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, April 25, 2001 15:45
> > To: '[EMAIL PROTECTED]'
> > Subject: How can I use a Image as a submit button using struts 
> > 
> > 
> > Hi,
> > Can anybody tell me how I can simulate the functionality of 
> > 
> > <Img Type = Submit />
> > I mean I need to use an Image as a submit button.
> > 
> > 
> > Thanks,
> > Uday.
> > 
> 

Reply via email to