struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Husted <hus...@apache.org>
Subject Re: HTML:Image (was: HTML / Struts Help)
Date Fri, 15 Feb 2002 13:13:24 GMT
The advice in the User Guide may be obsolete now that we support the
dotted syntax :o(

You may need to define a ImageButtonBean on the ActionForm with x and y
properties. The getCreateButton method could then call the getX() (or
getY()) method on that bean to determine whether it was pushed. 

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/


Mark Takacs wrote:
> 
> > You can use the <html:image> tag and set the property
> > to a value. Then in the action, you are able to find out,
> > which button was presed
> 
> Ok, this sounds fine, cept Im running into the .x .y problem outlined
> in the HTML:IMAGE docs.   Has anyone gotten this working with the
> html:image tag?  None of the dozen or so responses so far seem to
> address that point.
> 
> The html:image docs have this to say:
> 
> http://jakarta.apache.org/struts/struts-html.html
> 
> > <html:image property="property"  ... />
> > The property name of this image tag. The parameter names
> > for the request will appear as "property.x" and "property.y",
> > the x and y representing the coordinates of the mouse click
> > for the image. A way of retrieving these values through a form
> > bean is to define getX(), getY(), setX(), and setY() methods,
> > and specify your propery as a blank string (property="").
> 
> ARG!  What if I *need* to use a named property to tell two images
> apart??
> 
> If I use
> 
> <html:image property="createButton" src="create.gif" />
> <html:image property="deleteButton" src="delete.gif" />
> 
> They do indeed show up as "createButton.x=6" and "createButton.y=10",
> when I dump the request.  However, my  setCreateButton() never gets
> called.  I assume there's a "createButton.x" being tossed in the way.
> Mmking a methods called setCreateButtonX() didnt seem to help
> 
> Following the suggestion in the docs
> 
> <html:image property="" src="create.gif" />
> <html:image property="" src="delete.gif" />
> 
> I can then create "setX()" and "setY()" which do get called.  However,
> I can no longer tell which button they pushed.. the create or the
> delete button.  My webdesign folks will *never* let me use a generic
> html submit button, it's GOT to be an image.
> 
> Here's what I'd like, following the suggestions so far.
> 
> page.jsp
>       <html:image property="createButton" src="create.gif" />
>       <html:image property="deleteButton" src="delete.gif" />
> 
> bean.jsp
>       boolean createButton;
>       public void setCreateButton__???___(String createButtonParm) {
>            createButton = true;
>       }
>       public boolean isCreateButton() {
>            return createButton;
>       }
> 
> action.java
>       if (formBean.isCreateButton())
> 
> 
> I would really like to use the Form get/set method outlined above,
> instead of scrolling thru the entire Request object looking for
> parameters that start with "createButton.x".   It seems like I just
> need to figure out how to name the setter/getter methods in my bean so
> that the <html:image ..> tag actually calls the right part of the bean.
> 
> Currently Im looking thru the html:image taglib code...  urgh.
> 
> -tak
> 
> __________________________________________________
> Do You Yahoo!?
> Got something to say? Say it better with Yahoo! Video Mail
> http://mail.yahoo.com
> 
> --
> To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message