我如何将值从jQuery传递到jsf h:inputText和Backing Bean [英] How can I pass value from jQuery to jsf h:inputText and Backing Bean
本文介绍了我如何将值从jQuery传递到jsf h:inputText和Backing Bean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试将值从jquery传递到jsf和Backing Bean.在此过程中,我不想使用jsf-Tag中的f:ajax.
I try to pass value from jquery to jsf and Backing Bean. And in the process, I do not want to use f:ajax from jsf-Tag.
javaScript或jQuery
javaScript or 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>
Bean内容
private String changevalue;
public String getChangevalue() {
return changevalue;
}
public void setChangevalue(String changevalue) {
this.changevalue = changevalue;
}
推荐答案
只是您必须将val设置为jquery中的浏览器文本框ID
just you have to set val to browser textbox id in jquery
例如
<script>
var myvalue = null;
$('.classname').live('click',function(){
myvalue = "thisvalue"+xyz;
$("#myid\\:fragment").val(myvalue);
});
</script>
它将自动将值绑定到您的bean
希望对您有帮助.
这篇关于我如何将值从jQuery传递到jsf h:inputText和Backing Bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文