struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keith <keithbaconstr...@yahoo.com>
Subject Re: HTML:Image (was: HTML / Struts Help)
Date Fri, 15 Feb 2002 10:05:21 GMT
A quick reply & probably crazy. But struts would try to call 
   formBean.getCreateButton().setX();

(It would I assume not try to call  formBean.getCreatebutton().getX()).

it might be worth trying in your form bean:-

public class formBean extends ActionForm {
   CreateButton createButton = new CreateButton();

   public CreateButton getCreateButton() {
      return CreateButton
   }
   //
   // I never know if you have to define a matching get/set pair
   // even if one of them has no use.
   //
   public CreateButton setCreateButton(ccc) {
      createButton = ccc;
   }


}
/*
* you'd probably have to make this public in it's own file!
*/

class CreateButton {
	private int x = 0;
	public void setX(int x) {this.x=x;}
	public int getX() {return x;}
}




--- Mark Takacs <mtakacs@yahoo.com> 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>
> 


__________________________________________________
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>


Mime
View raw message