Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can just inject the MarkerLocationer into AddProjectToDB and retrieve the value from there. There is no need to use hidden fields. Like this:</p> <p><strong>MarkerLocationer.java (Updated)</strong></p> <pre><code>@ManagedBean @SessionScoped public class MarkerLocationer implements Serializable { private static final long serialVersionUID = 4288587129736579882L; private MapModel draggableModel; public MarkerLocationer(){ draggableModel = new DefaultMapModel(); //Shared coordinates LatLng coord1 = new LatLng(41.017599, 28.985704); //Draggable draggableModel.addOverlay(new Marker(coord1, "Projenin olduğu yere sürükleyin.")); for (Marker marker : draggableModel.getMarkers()) { marker.setDraggable(true); } } public MapModel getDraggableModel() { return draggableModel; } public void setDraggableModel(MapModel draggableModel) { this.draggableModel = draggableModel; } public void onMarkerDrag(MarkerDragEvent event) { // since marker's state is already kept in draggableModel you do not necessarily } public LatLng getMarkerPosition(){ return draggableModel.getMarkers().get(0).getLatlng(); } } </code></pre> <p><strong>AddProjectToDB.java (Updated)</strong></p> <pre><code>@ManagedBean @ViewScoped public class AddProjectToDB { @ManagedProperty(value = "#{markerLocationer}") private MarkerLocationer markerLocationer; public void setMarkerLocationer(MarkerLocationer markerLocationer) { this.markerLocationer = markerLocationer; } public void save() { double lat = markerLocationer.getMarkerPosition().getLat(); double lon = markerLocationer.getMarkerPosition().getLng(); //.. your stuff } } </code></pre> <p><strong>And the JSF page</strong></p> <pre><code>&lt;h:form&gt; &lt;p:growl id="growl" showDetail="true" /&gt; &lt;script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"&gt;&lt;/script&gt; &lt;p:gmap center="41.017599,28.985704" zoom="13" type="HYBRID" model="#{markerLocationer.draggableModel}" style="width:600px;height:400px"&gt; &lt;p:ajax event="markerDrag" listener="#{markerLocationer.onMarkerDrag}" update="growl" /&gt; &lt;/p:gmap&gt; &lt;p:commandButton value="Projeyi Kaydet" icon="ui-icon-disk" action="#{addProjectToDB.save}"/&gt; &lt;/h:form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload