【发布时间】:2014-03-20 14:11:44
【问题描述】:
我必须将使用 html5 地理位置获得的地理位置值传递给我的托管 bean ItemMb,这是我的代码来澄清事情,我真的不知道如何实现这一点。
我的托管 bean
public class ItemMb {
private Item item = new Item();
// get/set
}
我的 dto 项目
public class Item {
// private Double idCollect;
// login et password
private Double lat;
private Double lon;
private Double accuracy;
private String photo;
private String remark;
public Item(){
}
// getters and setters
这是我的 .js 文件,我在其中获取了地理位置值并在一些 primefaces 标记中对其进行了内文
window.watchID = navigator.geolocation.watchPosition(function(position){
document.getElementById("xCurrentPosition").innerHTML = (Math.round(position.coords.latitude*100) / 100);
document.getElementById("yCurrentPosition").innerHTML = (Math.round(position.coords.longitude*100) / 100);
document.getElementById("accuracyCurrentPosition").innerHTML = position.coords.accuracy;
});
现在我想将那些 JavaScript 生成的地理位置值传递给我的托管 bean ItemMb。如果您需要更多信息,请随时询问。
【问题讨论】:
-
您如何向服务器发起请求以初始化托管 bean:通过更改当前 URL 的 GET 请求或通过 ajax 请求?
-
通过 GET 请求,对于我的页面导航,我使用 prettyfaces
标签: javascript jsf primefaces geolocation