You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Norbert Spemm <no...@gmx.de> on 2003/09/27 03:24:54 UTC
html_image property value not submitted
Hi,
I wanted to replace the buttons on my form with images.
Before I had a working application with this tag in the jsp:
<html:submit property='SubmittedAction' styleId='button'
value="Save"/>
now I tried with
<html:image property='SubmittedAction' styleId='button' value="Save"
page="/images/save.gif"/>
The problem with the image-version is, that my action now doesn't
receive a value for the parameter "SubmittedAction" anymore. Instead I
only get the parameters SubmittedAction.x and SubmittedAction.y which
are of no use for me.
What am I doing wrong? I'm using Struts 1.1
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: html_image property value not submitted
Posted by Norbert Spemm <no...@gmx.de>.
Hi Steve,
> The "value" attribute of an HTML 'input type="image"' tag (i.e., what
> the Struts <html:image> tag is generating) is apparently ignored by
> all (most?) browsers. See:
>
> http://www.blooberry.com/indexdot/html/tagpages/i/inputimage.htm
wow, that's pretty lame.
> One solution is to have a hidden variable in your HTML form
> associated with your form bean (let's use the bean property
> name "action") and then use JavaScript to set this property
I'm rigid thinking that no web page really _requires_ JavaScript, not at
least because some clients using my application will not allow active
scripting in their browser. Sites like e. g. www.hp.com (view with
disabled JS) make me feel confirmed.
Isn't it possible to iterate the request parameters if there's one that
has ".x" and ".y" suffix? Since no one really wants to submit values
with a name like this I suggest the struts framework automatically
generates a parameter so the handling in the action is consistent as for
a submit button. Of course there has to be some tag defining the name of
the "action" parameter.
Wouldn't that be nice?
This method work for me:
String getActionParameter(Map p_Keys)
{
String l_Key;
Iterator l_iKeys = p_Keys.keySet().iterator();
while (l_iKeys.hasNext())
{
l_Key = (String)l_iKeys.next();
if( l_Key.endsWith(".x")
&& p_Keys.containsKey(l_Key.substring(0, l_Key.length()-1)
+ "y"))
{
return l_Key;
}
}
return null;
}
To be used in the execute method of the action:
String l_Action = getActionParameter(p_Request.getParameterMap());
Thanks for help
Nobi
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: html_image property value not submitted
Posted by Steve Armstrong <bi...@sympatico.ca>.
The "value" attribute of an HTML 'input type="image"' tag (i.e., what the
Struts <html:image> tag is generating) is apparently ignored by all (most?)
browsers. See:
http://www.blooberry.com/indexdot/html/tagpages/i/inputimage.htm
One solution is to have a hidden variable in your HTML form associated with
your form bean (let's use the bean property name "action") and then use
JavaScript to set this property appropriately on submit. Something like,
<html:hidden property="action"/>
<html:image property="" styleId="button" page="/images/save.gif"
onclick='document.forms["myForm"].action.value="Save";
document.forms["myForm"].submit();' />
In the action associated with your form, you can then consult the "action"
property of your form bean to determine the type of image button that has
been selected.
Cheers,
-Steve
-----Original Message-----
From: Norbert Spemm [mailto:no_more_spam@gmx.de]
Sent: Friday, September 26, 2003 9:25 PM
To: struts-user@jakarta.apache.org
Subject: html_image property value not submitted
Hi,
I wanted to replace the buttons on my form with images.
Before I had a working application with this tag in the jsp:
<html:submit property='SubmittedAction' styleId='button'
value="Save"/>
now I tried with
<html:image property='SubmittedAction' styleId='button' value="Save"
page="/images/save.gif"/>
The problem with the image-version is, that my action now doesn't
receive a value for the parameter "SubmittedAction" anymore. Instead I
only get the parameters SubmittedAction.x and SubmittedAction.y which
are of no use for me.
What am I doing wrong? I'm using Struts 1.1
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org