簡體   English   中英

p:commandButton起作用

[英]p:commandButton mull functioning

p:commandButton沒有要在actionListener調用的方法。 我剛剛使用它來隱藏對話框editSensorDialog但是它在p:selectOneMenuvalueChangeListener調用了addDeviceMappings方法。

我的代碼中有什么錯誤,為什么p:commandButton調用不必要?

上述問題的完整代碼:

    <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>

最簡單的方法是將JavaScript從onsuccess改為onclick並停止傳播。

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

另外,使用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