Hi,

Yes, it seems there are some problems with the <html:image>, if you want to use the 
value. I find the attached information in the mail-archive (from April, 2001). I'm not 
sure if Craig or Ted or someone else, reported the (browser)-bug once (maybe, they can 
tell us :-). I figured out, that a possible solution to handle different buttons is 
the following:

In the JSP I just define a property (for example):

<html:image srcKey="yourSourceKeyName"                                                 
                                                                 
altKey="yourAltKeyName"
                style="yourStyleIfYouHaveIt"
                property="propertyNameOfImage"  />

Then in your ActionForm you can find out about the pressed button like this:

Enumeration attr = request.getParameterNames();
String att;
while(attr.hasMoreElements()){
        att = (String)attr.nextElement();
        System.out.println("parameter name:" + att + "... value:" + 
request.getParameter(att));
        if(att.equals("propertyNameOfImage.x")){  // or check for propertyName.y
                ......
        }
}

For the other button, you just define an other property name. O.k., it would be much 
nicer, if the "value" parameter would work, but at least, this can help.

Cheers, Marcel

---------------------------------------------------------------------------------------------------

    * From: Dirk Jaeckel
    * Subject: Re: Multiple Submit Buttons per Form
    * Date: Mon, 17 Sep 2001 04:35:58 -0700

On Sat, Sep 15, 2001 at 09:21:47AM +0200, Marcel Andres wrote:
> Hi
> >I handle something like this, how you describe it at last. I
>route both buttons to a single action class, and this class decides,
>based on the pressed button (value), what to do.

How do you do this with image-buttons (<html:image>)?
The value is not submitted then, at least not with netscape 6.1 and IE 5.5.

I tried this:

<html:form action="/map" method="GET">
<html:image value="foo" property="layers" page="/img/update.gif" border="0" />
<html:image value="bar" property="layers" page="/img/update.gif" border="0" />
</html:form>

BTW: While rendering the page, getLayers is called. But I don't know whats done with 
the result.

The only thing that is submitted is: ?layers.x=50&layers.y=1 

I am not interested in the X- and Y-Coordinates. But I need to know
which button was pressed. Do you know the name(s) of the Method(s)
that are called in the form bean?

It is not:

 public void setLayers(String in);
 public void setLayers(String[] in);
 public void setLayers_X(String in);
 public void setLayers_Y(String in);
 public void setLayersX(String in);
 public void setLayersY(String in);
 

Dirk

RE: [Fwd: FW: REPOST: How to code and use the html:image
tag?]



     From: Ware, John 
     Subject: RE: [Fwd: FW: REPOST: How to code and use the html:image tag?] 
     Date: Fri, 13 Apr 2001 17:19:09 -0700 



It doesn't work on either of the browsers I have on my system. 

Craig, can you cast the tie breaking vote on this? Being a newbie, I don't
want to post a bug report without being certain it is a bug.

john



-----Original Message-----
From: Zhengxi Ruan [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 13, 2001 6:10 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [Fwd: FW: REPOST: How to code and use the html:image tag?]


it is not a bug of Struts, but the browser's.

Jesse

-----Original Message-----
From: Ted Husted [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 13, 2001 7:52 PM
To: [EMAIL PROTECTED]
Subject: Re: [Fwd: FW: REPOST: How to code and use the html:image tag?]


You're right. This doesn't seem to be working. I'd report it as a bug. 

< http://nagoya.apache.org/bugzilla/ >

[EMAIL PROTECTED] wrote:
> 
>  Ted,
>         I tried this with no success. I put two html:image tags into my
> login.jsp
> 
> <tr><td></td><td><html:image page="/images/lanikai.jpg" property =
> "login" value="lanikai" /><td></tr>
> <tr><td></td><td><html:image page="/images/larry.jpg" property = "login"
> value="larry" /><td></tr>
> 
> In the perform method of LoginAction.java I traverse the Enumeration
> returned by request.getParameters() looking for a parameter named login.
> It's not there. :-(
> 
> Here's the code:
> 
>        java.util.Enumeration enum = request.getParameterNames();
>         while( enum.hasMoreElements() ){
>             String str = (String) enum.nextElement();
>             System.out.println( str + " => " + request.getParameter( str
> ) );
> 
>         }
> and the output:
> 
> course => pebblebeach
> login.y => 147
> login.x => 129
> 
> I have a html:select named course set to pebblebeach. I DO get the
> mouseclick x and y values. So, I'm seeing something from my login
> control.
> 
> I don't see what I'm doing wrong.
> 
> thanks
> 
> john ware
> 
> -----Original Message-----
> From: Ted Husted [mailto:[EMAIL PROTECTED]]
> Sent: Friday, April 13, 2001 12:59 PM
> To: [EMAIL PROTECTED]
> Subject: Re: REPOST: How to code and use the html:image tag?
> 
> The property and value for the button is passed as a parameter
> (property=value), that you can retrieve from the request context.
> 
> A typical approach would be to give each button the same property but
> different values, like
> 
> <html:image page="/images/login.gif" alt="Login" property="login"
> value="havePassword" />
> <html:image page="/images/forgotpassword.gif" alt="Forgot Password"
> property="login" value="forgotPassword" />
> 
> Then in the action method, you would use a pattern like
> 
> string loginType = request.getParameter("login") ;
> if loginType.equals(""forgotPassword") { forward to forgotPassword page
> }
> if loginType.equals("havePassword") { validate password  }
> 
> "Suriyanarayanan, Senthil Kumar" wrote:
> > What methods should I code inside my LoginForm corresponding to those
two
> > buttons? How to code the properties (loginButton, forgotPasswordButton).
> I'm
> > more concerned about whether a particular button is clicked rather then
> > their co-ordinates.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/

Reply via email to