1 2 Previous Next 20 Replies Latest reply on Feb 17, 2016 4:52 AM by Michal Petrov

    a4j:commandButton, actionListener, event.data always false

    Arnie Morein Novice

      I have a a4j:commandButton labeled "add" that brings up a rich:popupPanel to perform an add action in a modal dialog. The Save and Update buttons:

       

      <a4j:commandButton id="cmdSaveModalCommentEdit" 
          value="#{messages.getString('application.lbl.cmdSave')}" 
          action="#{infoPersonCommentEdit.save}" 
          render="panelModalInfoPersonCommentEdit" execute="@form" 
          data="#{infoPersonCommentEdit.okToClose}" 
          oncomplete="if (!event.data) { return false; } else { #{rich:component('modalInfoPersonCommentEdit')}.hide(); };"  
          rendered="#{empty infoPersonCommentDTOCDI.id}" > 
          <f:param name="cid" value="#{javax.enterprise.context.conversation.id}"/>
      </a4j:commandButton>
      
      <a4j:commandButton id="cmdUpdateModalCommentEdit" 
          value="#{messages.getString('application.lbl.cmdUpdate')}" 
          action="#{infoPersonCommentEdit.update}" 
          render="panelModalInfoPersonCommentEdit" execute="@form" 
          data="#{infoPersonCommentEdit.okToClose}" 
          oncomplete="if (!event.data) { return false; } else { #{rich:component('modalInfoPersonCommentEdit')}.hide(); };"  
          rendered="#{not empty infoPersonCommentDTOCDI.id and !infoPersonCommentDTOEdit.readOnly}" >
          <f:param name="cid" value="#{javax.enterprise.context.conversation.id}"/>
      </a4j:commandButton>
      
      

       

      Control whether the modal closes based on a variable (okToClose) on the backing bean. During an add, the saveListener executes, saves the new record, and sets OkToClose to Boolean.TRUE. But during oncomplete event.data is false (normally, it would only be false after the listener's execution if there was a validation error) so the dialog isn't closed, but is then repainted as it would be in Update mode. If I then update the field values and click update, the update listener fires and the dialog closes; like it is supposed to.

       

      The dialog is opened from a contextual menu that is a per-row column of a data grid:

       

      <h:outputLabel id="labelActionTabComment" for="menuActionTabComment" value="#{messages.getString('application.lbl.cmdClick')}" />
          
      <rich:contextMenu id="menuActionTabComment" style="width:10%;" target="labelActionTabComment" mode="client" showEvent="click" >
          <rich:menuItem id="menuInfoPersonCommentEdit" 
              actionListener="#{infoPersonCommentList.editListener}" 
              execute="@this" mode="ajax"
              data="#{infoPersonCommentList.okToOpen}" 
              oncomplete="if (event.data) { #{rich:component('modalInfoPersonCommentEdit')}.show(); } "  
              label="#{messages.getString('application.lbl.linkEdit')}"  
              render="panelModalInfoPersonCommentEdit" >
              <f:param name="cid" value="#{javax.enterprise.context.conversation.id}" />
          </rich:menuItem>
          <rich:menuItem id="menuInfoPersonCommentView" 
              actionListener="#{infoPersonCommentList.viewListener}"  
              execute="@this" mode="ajax"
              label="#{messages.getString('application.lbl.linkView')}" 
              data="#{infoPersonCommentList.okToOpen}" 
              oncomplete="if (event.data) { #{rich:component('modalInfoPersonCommentEdit')}.show(); } "  
              render="panelModalInfoPersonCommentEdit" >
              <f:param name="cid" value="#{javax.enterprise.context.conversation.id}" />
          </rich:menuItem>
      </rich:contextMenu>
      
      

       

      Starting an update operation brings up the dialog and after the update the modal is closed.

       

      I can't see what's going on. I've verified that the Conversation is injected into each bean and is passed via f:param as shown above. It almost seems like the the data isn't being serialized at the right time? or is the bean instance used during serialization new and not the one that was run during the save operation?

        1 2 Previous Next