Skip to content Skip to sidebar Skip to footer

Passing Javascript Variable To Java Bean

I am trying to get coordinates from leaflet map ( javascript) and passing them to my managed bean. In order to send javascript variable to my managed bean, I used the answer here

Solution 1:

You don't need a form and all this stuff.

<p:remoteCommand name="myRemote" partialSubmit="true" process="@this"  action="#{mapbean.displayLatLong()}"/>

functiononClick(e) {
  myRemote([
    { name: 'latt',  value: e.latlng.lat },
    { name: 'longt', value: e.latlng.lng }
  ]);
};

and at server side

Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();

String latt  = params.get("latt");
String longt = params.get("longt");

Post a Comment for "Passing Javascript Variable To Java Bean"