简体   繁体   English

Ajax在Primefaces中调用CommandButton

[英]Ajax call in primefaces for commandbutton

    <p:column id="column2"  >
    <f:facet name="header">
        <h:outputText value="Parameter Description" ></h:outputText>
    </f:facet>
        <h:outputText value="#{param1.parameter}"/>  

</p:column>
<p:column id="column4" >
    <f:facet name="header">
        <h:outputText style="width:30px;margin-left:20px" value="Unit" ></h:outputText>
    </f:facet>
        <h:outputText value="#{param1.parameterUnit}"></h:outputText >
</p:column>
 <p:column id="column5" >
    <f:facet name="header">
        <h:outputText value="Value Range" ></h:outputText>
    </f:facet>
        <h:outputText value="#{param1.parameterValuerange}"></h:outputText >
</p:column>
<p:column id="column3" >
    <f:facet name="header">
        <h:outputText style="margin-left:100px;width:70px;" value="Value" ></h:outputText>
    </f:facet>
        <h:inputText id="valuefield" value="#{param1.parameterValue}" onkeyup="return validateParameterInput(event,this,'#{param1.parameterValuerange}')">
        <f:validateRequired />
        </h:inputText >
</p:column>

    </p:dataTable>
    </div>
  <div style="width: 1000px;">

  <p:commandButton styleClass="btn" id="actbtn"  action="#{ParameterMB.loadParameters()}" style="margin-top:10px;margin-left:50px;" onclick="return myFunction()" value="Apply">

            <f:ajax execute="table" render="table" />

        </p:commandButton>

when i am trying to load the datatable on the click of apply button it is not making a ajax request....can someone explain what i am doing wrong...thanks in advance 当我尝试在单击“应用”按钮上加载数据表时,它没有发出ajax请求。...有人可以解释我在做什么错...预先感谢

you're using f:ajax inside p commandbutton - in general its incompatable. 您在p命令按钮中使用了f:ajax-通常它是不兼容的。 Change it to 更改为

<p:ajax process="table" update="table" />

change your action to an actionListener as well and remove the () on the method call. 同时将动作更改为actionListener,并删除方法调用上的()。 I'm assuming you want to stay on the same page as you dont have ajax="false" on ap:commandbutton 我假设您想停留在同一页面上,因为您在ap:commandbutton上没有ajax =“ false”

What does : return myFunction() do? 返回myFunction()的作用是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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