0

我有一个 jquery 文件:

document.getElementById('formId:someId').click();
bla = document.getElementById('formId:inputId3').value;            
              if(bla =="koko") {
 alert(" Done ");
 }

在 jsf 我有改变 h:inputText 值的方法:

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

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

在托管bean中我有:

   public void exec2() {
    this.testvalue2 = "koko";    
   }

问题我无法if在 Jquery 中输入,因为它们在更改之前仍然具有第一个默认值。

在单击按钮之前,我如何更新 Jquery 中的 inputText ?

4

1 回答 1

0

你的代码应该是这样的(它的一般想法):

document.getElementById('formId:someId').click();

并添加以下js函数:

function doTheJs(data) {
    if (data.status === 'success') {
        bla = document.getElementById('formId:inputId3').value;            
        if(bla =="koko") {
            alert(" Done ");
        }
    }
}

和你的 JSF:

<h:commandButton id="someId" value="Button" action="#{gestionduplanning.exec2()}" style="display:none">
    <f:ajax render="inputId3" execute="@all" onevent="doTheJs"/>  
</h:commandButton>
于 2013-05-29T11:03:24.610 回答