I have tried various methods of getting the mouse coordinates into the backing bean when a user clicks on an image. I can get the coordinates in the javascript, it then calls the ajax listener, but the parameters are not in the request.
my js:
if (!cis) var cis = {}
if (!cis.sarwinds) {
var focusLostTimeout
cis.sarwinds = {
errorHandler: function(data) {
alert("Error occurred during Ajax call: " + data.description)
},
updateZoomValues: function(input, event) {
jsf.ajax.addOnError(cis.sarwinds.errorHandler)
var offset = jQuery(input).offset();
jsf.ajax.request(input, event, {
render: "imagePan2 message",
x: event.pageX - offset.left,
y: event.pageY - offset.top
})
},
getGraphicImageId: function(input) {
var clientId = new String(input.name)
var lastIndex = clientId.lastIndexOf(":")
return clientId.substring(0, lastIndex) + ":imagePan2"
}
}
}
My jsf page element:
<h:graphicImage id="imagePan2" library="images" styleClass="wind_map" name="testImage.jpg" style="#{SarWindsImagesBean.imageStyle('testImage.jpg')}">
<f:ajax event="click" onevent="cis.sarwinds.updateZoomValues(this, event)" listener="#{SarWindsImagesBean.zoomInClick}" render="imagePan2 message"/>
</h:graphicImage>
My Backing bean:
public void zoomInClick(AjaxBehaviorEvent event) {
double width;
double height;
double top;
double left;
double mouseX;
double mouseY;
String fileName = "testImage";
Map<String, String> reqParams = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
mouseX = Double.parseDouble(reqParams.get("x"));
mouseY = Double.parseDouble(reqParams.get("y"));
width = imageItems.get(fileName).getImageWidth() * 1.1;
height = imageItems.get(fileName).getImageHeight() * 1.1;
// We need the mouse position on the image here, and we need to calculate
top = mouseY - ((mouseY - imageItems.get(fileName).getImageTop()) * 1.1);
left = mouseX - ((mouseX - imageItems.get(fileName).getImageLeft()) * 1.1);
if (this.imageLock == false){
imageItems.put(fileName, new SarWindImageItem(width, height, top, left));
} else {
Iterator<String> it = imageItems.keySet().iterator();
while (it.hasNext()) {
String key = (String)it.next();
imageItems.put(key, new SarWindImageItem(width, height, top, left));
}
}
}
The reqParams are empty.
Dan