简体   繁体   中英

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

you're using f:ajax inside p commandbutton - in general its incompatable. Change it to

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

change your action to an actionListener as well and remove the () on the method call. I'm assuming you want to stay on the same page as you dont have ajax="false" on ap:commandbutton

What does : return myFunction() do?

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