Zincode
Zincode

Reputation: 14471

Javascript not update value of h:inputHidden

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);
    }

Upvotes: 1

Views: 973

Answers (1)

TalesTk
TalesTk

Reputation: 181

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" />

Upvotes: 1

Related Questions