简体   繁体   中英

how to update h:inputtext in jsf

in Jquery i am sending value to managed bean with success

document.getElementById('formId:inputId').value = "blavla";
document.getElementById('formId:someId').click();

and my jsf code is :

 <h:inputText id="inputId" value="#{gestionduplanning.testvalue}" >
 <f:ajax/>
 </h:inputText>
 <h:inputText id="inputId3" value="#{gestionduplanning.testvalue2}" /> 

 <h:commandButton id="someId" value="Button" action="{gestionduplanning.exec2(gestionduplanning.testvalue)}" style="display:none">
 <f:ajax render="someId" execute="@all"/>  
 </h:commandButton>

and my managed bean methode :

   public void exec2(String x) {

    this.testvalue2 = testvalue;   

   }

the problem is when i give the value of testvalue to testvalue2 i have nothing .

how i can give the value to this value and be showen in the h:inputText

I did it with Primefaces before. Maybe It can help you;

Here is my code part in page;

<p:commandButton id="linkButton2" process=":form:receivedMessage"
            style="display:none" />

<h:inputText id="receivedMessage" style="display:none"></h:inputText>

And the Javascript code part;

document.getElementById('form:receivedMessage').value = 'myValue';
document.getElementById('form:linkButton2').click();

These code parts worked for me to send data from javascript to backing managed bean.

When your command button is clicked your bean variable will also be filled by input value. So you don't need to send it as a function parameter.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM