views:

60

answers:

1

Hi, sorry if the answer to this is obvious but I couldn't find it.

How do I detect if the user has clicked, dragged etc. on an image (or other element)?

Thanks in advance!

+1  A: 

There are several way of doing this:

In HTML it would be something like:

<img src="images/myImage.jpg" onclick="someJSFunc()"/>

In the case of Richfaces you'd probably want to invoke some sort of server side logic through an Ajax request after your image has been clicked, so, the most appropriate thing would be:

<img src="images/myImage.jpg">
 <a4j:support event="onclick" action="#{myBean.someActionMethod}" reRender="someComponent"/>
</img>

For more information of how to add Ajax behavior to standard HTML components tags with Richfaces see the a4j:support component description.

StudiousJoseph
Something more. How do I get the position of the mouse? Thanks!
Panayiotis Karabassis
@Panayiotis please post a new question for that
Odelya