4 Replies Latest reply on Jun 4, 2014 8:22 AM by saurabhcdt

    valueChangeListener of rich:comboBox getting called on submit which is unintended

    saurabhcdt

      I'm facing a issue where on changing rich:comboBox value, i need to call backing bean. So i'm using valueChangeListener with a4j:support event="onchange" as bellow:

      <rich:comboBox value="#{myBean.name}" defaultLabel="#{messages['dropdown.defaultText']}" label="#{messages['label.name']}" status="defaultStatus" valueChangeListener="#{myBean.checkToChangeName}" disabled="#{myBean.isAdminUser}" > <f:selectItems value="#{myBean.nameList}" /> <a4j:support event="onchange" reRender="errTable,popUpPanel" oncomplete="if(#{myBean.showPopup}) #{rich:component('popUpPanel')}.show();" /> </rich:comboBox> 

      The backing bean method:

      public boolean checkToChangeName(ValueChangeEvent event){ // Code to check change is valid & its impact on other fields } 

      The method checkToChangeName() should get call only on change event. But in my case, the methods is getting called on change event & also getting called on submit of the form which i don't need & creating trouble.

      I'm using h:commandButton as bellow to submit the form:

      <h:commandButton id="btnSave" value="#{messages['action.save']}" action="#{myBean.updateProfile}" reRender="profileForm" /> 

      Can anyone help me to understand why its calling checkToChangeName() method on submit? & How can i prevent it?