Javascript with JSF
Javascript with JSF
我正在使用Google Maps API在客户端获取用户位置。。。然后,我想将其发送到服务器端进行一些处理,并填充一个选择框(使用本地地址)。
做这件事最好的方法是什么?我更愿意按下一个按钮并使用ajax填充框。
谢谢!
下面是一个如何使用Ajax将Javascript值(用户位置)传递给bean的示例。
该位置将存储在<h:inputHidden>
字段中。<f:ajax>
的execute属性指定将发送到服务器进行处理的值。
<h:form id="formname">
<h:inputHidden value="#{indexBean.value}" id="hvalue" />
<h:commandButton value="action" onclick="getLocation();" action="#{indexBean.doSome}">
<f:ajax execute="hvalue" render="output" />
</h:commandButton>
<h:outputText value="#{indexBean.output}" id="output" />
</h:form>
在发送Ajax请求之前,<h:commandButton>
的onclick属性指定要执行的Javascript函数。Javascript函数应该在隐藏字段中设置值。
function getLocation() {
document.getElementById("formname:hvalue").value = "TEST";
}
<f:ajax>
的呈现属性指定要在客户端更新的内容。在这种情况下是<h:outputText>
,在您的情况下,它将是您的<h:selectOneMenu>
。
相关文章:
- 如何通过ajax刷新JSF填充的javascript变量
- Fighting with FRP
- issue with FB.Event.subscribe
- 当我点击jsf中的primefaces命令按钮时,如何获得点击事件
- geolocation-marker.js conflict with markerclusterer.js
- Angular 2.0 with JavaScript or TypeScript?
- 为什么不推荐使用“with”?是否有更好或其他方法可以“下降”到对象的命名空间
- WebComponentsJS with IE10
- jsf中两个字符串的颜色代码差异
- 指令的模板必须只有一个根元素:With restrict E&替换true
- timeago.js with datatable and PHP
- Ajax and Json with Rails
- errors with Javascript try catch
- how to split a string with ','
- Understanding Javascript scope with "var that = this&qu
- Architecture for CPU intensive tasks with NodeJS & Socke
- How to declare a Map containing certain properties with flow
- 设置'这'在React with Inverse Data Flow中
- Twitter Bootstrap with Primefaces (JSF)
- Javascript with JSF