简体   繁体   English

p:commandButton起作用

[英]p:commandButton mull functioning

p:commandButton have no method to call in actionListener . p:commandButton没有要在actionListener调用的方法。 I have just used it for hiding dialog editSensorDialog But its calling the method addDeviceMappings in p:selectOneMenu 's valueChangeListener . 我刚刚使用它来隐藏对话框editSensorDialog但是它在p:selectOneMenuvalueChangeListener调用了addDeviceMappings方法。

any thing wrong in my code, why p:commandButton calling unnecessary? 我的代码中有什么错误,为什么p:commandButton调用不必要?

Complete code of above issue : 上述问题的完整代码:

    <p:dialog id="editSensorDialog" style="width: 360px;" width="360" height="400"
              modal="true" widgetVar="editSensorDialog" resizable="false" >

      <p:dataTable id="editSensorList" value="#{sensorController.sensorsMappingList}"
                   var="item" rowIndexVar="rowIndex">

         <p:column headerText="#{bundle['label.Sensor']}" id="editdeviceName">    
           <h:outputText rendered="false" value="#{item.value}"/> 
           <p:selectOneMenu valueChangeListener="#{sensorController.addDeviceMappings}"> 
             <p:ajax update="@this"/>
             <f:selectItems value="#{item.value}" var="sensor" itemLabel="#{sensor}"
                            itemValue="#{item.name}+#{sensor}"/>
           </p:selectOneMenu>
         </p:column>

     <f:facet name="footer">  
       <p:commandButton value="#{bundle['label.Submit']}"
                        onsuccess="editSensorDialog.hide()"/>
     </f:facet> 
</p:dataTable>

The easiest way would be to change your JavaScript from onsuccess to onclick and stop propagation. 最简单的方法是将JavaScript从onsuccess改为onclick并停止传播。

<p:commandButton value="#{bundle['label.Submit']}" onclick="editSensorDialog.hide();return false;"/>

Also, usage of a p:commandButton is a bit overkill for that task, any plain HTML element will do the job ( <input type="button" value="#{bundle['label.Submit']}" /> or <a>#{bundle['label.Submit']}</a> etc. 另外,使用p:commandButton对该任务有点过大,任何简单的HTML元素都可以完成此工作( <input type="button" value="#{bundle['label.Submit']}" /><a>#{bundle['label.Submit']}</a>等。

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

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