Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

x,y coordinate of mouse click

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The struts documentation says that "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 property as a blank string (property="")."
My JSP page uses the image tag in the following manner
<html:image src='<%= map.getMap() %>' property=""/>
In the MapForm page I use the following
public class MapForm extends ActionForm {

private String x;
private String y;
public String getX() {
return x;
}

public String getY() {
return y;
}
public void setX(String string) {
x = string;
}
public void setY(String string) {
y = string;
}
}

The MapAction form has the following code
if (form != null) {
x = ((MapForm)form).getX();
y = ((MapForm)form).getY();
logger.info("The coords are :: " + x + " " + y);
}
My image displays OK. But when I click on the image I get the following error message. I am using Tomcat 4.1.24.
java.lang.NullPointerException
at com.psgs.action.MapAction.execute(MapAction.java:61)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
Please help.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic