my javascipt function not set value of inputHIdden in bean. maybe someone know the reason of this problem?
java
public String test = "";
//getter and setter
jsf
<h:inputHidden id="myInputHidden" value="#{bean.test}"/>
<p:commandButton value="Apply" actionListener="#{bean.filter}" onclick="set();"/>
javascript
function set() {
var str="test"
$("#myForm\\:myInputHidden").val(str);
}
Maybe you can try:
<p:commandButton value="Apply" actionListener="#{bean.filter}" onclick="#{bean.test}"/>
this way you don't need to have the JS function. If you want it to dinamically update add a Ajax call such as:
<f:ajax event="valueChange" render="@form" />
or
<f:ajax event="click" render="@form" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.