我尝试将值从jquery传递到jsf和Backing Bean。在此过程中,我不想使用jsf-Tag中的f:ajax。
javaScript或jQuery
<script>
var myvalue = null;
$('.classname').live('click',function(){
myvalue = "thisvalue"+xyz;
// update myvalue in jsf inputtext and in bean
});
</script>
JSF-内容
<h:form id="myid" prependId="false">
<h:inputText id="fragment" value="#{myBean.changevalue}">
<!-- please do not use here f:ajax or p:ajax so on. -->
</h:form>
豆含量
private String changevalue;
public String getChangevalue() {
return changevalue;
}
public void setChangevalue(String changevalue) {
this.changevalue = changevalue;
}
最佳答案
只是您必须将val设置为jquery中的浏览器文本框ID
例如
<script>
var myvalue = null;
$('.classname').live('click',function(){
myvalue = "thisvalue"+xyz;
$("#myid\\:fragment").val(myvalue);
});
</script>
它将自动将值绑定到您的bean
希望对您有帮助。