previous | index | next

Getting the Mouse Click Coordinates

When the request is sent from the client to the server, the mouse click coordinates are given as the values of the request parameters: where clientId is the ID (as a string) of the component that was clicked.

You get the client ID from the ActionEvent argument e passed to the action listener:

      FacesContext context = FacesContext.getCurrentInstance();
      String clientId = e.getComponent().getClientId(context);

Request parameters are part of the external context of a JSF life cycle. They can be obtained by:

      Map requestParams = 
         context.getExternalContext().getRequestParameterMap();

Now get the request parameter value (as a string) with:

      requestParams.get(clientId + ".x");

previous | index | next