1

p:commandButton have no method to call in actionListener. I have just used it for hiding dialog editSensorDialog But its calling the method addDeviceMappings in p:selectOneMenu's valueChangeListener.

any thing wrong in my code, why p:commandButton calling unnecessary?

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>

Teja Maridu
  • 515
  • 1
  • 6
  • 14

1 Answers1

-1

The easiest way would be to change your JavaScript from onsuccess to onclick and stop propagation.

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

Alexandre Lavoie
  • 8,711
  • 3
  • 31
  • 72