I have a JSF/richfaces application running on jboss 5.1 and I'm stuck at something.

I have the following thing that I need to do:

I have an image on the client site, and I need to set markers on that image. The coordinates of those markers need to be stored in DB.

The problem is with getting the x,y coordinates of the click event to the backend.

What I tried is this:h:commandButton with the image attribute pointing to a servlet which is generating the image, and an actionListener attribute where I catch the ActionEvent. The .x and .y don't seem to be transfered in Firefox. It does in IE I believe (not tested).

Now i'm trying to use mediaoutput to show the image, wrapping it with a div to call a javascript function on the onclick event, trying to get the x,y coords to be transfered to the serverside using a4j:actionparam in a a4j:jsFunction.

Everything I tried failed, and i'm kinda out of ideas.

Do you guys have something I could try to get this done?I know it's possible ... google maps does it all the time

how bout using an onclick event to capture the x and y coordinates and once you the coordinates call a a4j:jsFunction passing the values to the backend. here's an example jsFunction component thats take two arguments:

Ajax submit function has an 'event' parameter that incapsulates original dom event.On the other side, actionParam has 'escape' attribute that tells renderer how to interpret param value. If that attribute was set to 'false', the value will be encoded as JavaScript reference.Therefore, code like:<a4j:actionparam name="param1" value="event.clientX" assignTo="#{backingBean.x}" escape="false" />

I've tried that piece of code but it gives me the coordinates relative to the page. When I take those coordinates and draw a marker on the image the marker is shifted to the right by the amound of pixels the mouse pointer is removed from the left side of the page.

My image is in a form on modalPanel btw, maybe that has something to do with it.

If I could know the absolute coordinates of the image on the page, I would subtract that amount to get the correct coordinates relative to the image, but I see no way how.

For now, I've hardcoded this. I've placed the modalPanel with the left and top attributes on a predefined location. and with moveable false I can "measure" the coordinates by clicking on the upperleft corner of the image, and then I hardcoded those values to subtract from the x,y coords i'm getting from the form. that way, for now, the marker is drawn perfectly under my mousebutton, and the correct coordinates are stored in database.

Ofcourse, this can in no way be a sollution in production mode.Right now, I'm even thinking of rendering the image in an embedded flash application and catching the correct coordinates there.

I still can't believe that when you use a a4j:commandButton with the image attribute that it is so hard to get the x and y coordinates of the mouse click event on the button. Seems like a very basic feature to me.