0
我想在我的JSF-2/Primefaces-3應用程序中獲取經度和緯度。我使用下面的代碼:Action沒有在JSF2-Primefaces3應用程序中調用監聽器
XHTML
<h:inputText id="address" value="#{nyBean.address}" />
<p:remoteCommand name="rmtCommandGeocoder" actionListener="#{myBean.getCordinates}" />
JAVA SCRIPT
function geocoder() {
var geocoder = new google.maps.Geocoder();
var address = document.getElementById("address").value;
geocoder.geocode({
'address' : address
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
// Calls the remoteCommand "rmtCommandGeocoder",
// passing the coordinates to map of parameters
rmtCommandGeocoder([ {
name : 'latitude',
value : results[0].geometry.location.lat()
}, {
name : 'longitude',
value : results[0].geometry.location.lng()
}]);
}
});
}
BEAN
public void getCordinates() {
FacesContext context = FacesContext.getCurrentInstance();
Map<String, String> parameterMap = context.getExternalContext().getRequestParameterMap();
double latitude = Double.parseDouble((String) parameterMap.get("latitude"));
double longitude = Double.parseDouble((String) parameterMap.get("longitude"));
}
的這裏的問題是getCordinates()沒有被調用。任何線索傢伙?