aspose file tools*
The moose likes Struts and the fly likes x,y coordinate of mouse click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "x,y coordinate of mouse click" Watch "x,y coordinate of mouse click" New topic
Author

x,y coordinate of mouse click

Amarjyoti Das
Greenhorn

Joined: Mar 18, 2002
Posts: 16
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: x,y coordinate of mouse click