struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Andres <marcel.and...@csfs.com>
Subject Re: Multiple Submit Buttons per Form
Date Wed, 19 Sep 2001 10:55:04 GMT
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


Mime
View raw message