5 Replies Latest reply on Aug 27, 2008 9:04 PM by Rodolfo Burla

    Problem with long runnig conversation

    Rodolfo Burla Newbie

      Hi all,


      Im having some problem when I try to submit an ajax form during a long running conversation.
      The problem is that the first time i click on the submit button the form apparently is submitted, but the method was not invoked. But when I click the submit button for the second time the form is submitted and the method invoked.


      Anybody can help me??


      here is the code:



      <a4j:form id="permissionOUForm">     
                          <rich:simpleTogglePanel id="permissionOU" switchType="client" opened="false" label="#{messages['permission.ou.title']}"
                               styleClass="attribute-relationship"
                               headerClass="label"
                               bodyClass="field">
                               
                               <s:div styleClass="field-align-left">
                                    <h:outputText styleClass="bold" value="#{messages['permission.label']}" /><br />
                                    <h:selectOneMenu id="selectPermissionOU" value="#{ouController.permission}">
                                         <s:selectItems hideNoSelectionLabel="false" noSelectionLabel="#{messages['permission.selectOne']}" var="permission" value="#{permissionController.listPermissionsByPermissionEntityTypeWithTypeChildrenAndStatus('com.milestone.youknow.model.OU', 'ACTIVE')}" label="#{permission.name}">
                                         </s:selectItems>
                                         <a4j:support event="onchange" reRender="permissionOUUser" eventsQueue="populateLists" ajaxSingle="true"/>
                                         <s:convertEntity/>
                                    </h:selectOneMenu>
                               </s:div>
                                         
                               <s:decorate id="newPermissionOUUserList">
                                <rich:listShuttle id="permissionOUUser" 
                                          sourceValue="#{ouController.listOUsNotRelatedUser}"
                                          targetValue="#{ouController.listOUsRelatedUser}"
                                             var="ou"
                                             sourceListWidth="240px"
                                              targetListWidth="240px"  
                                             sourceCaptionLabel="#{messages['permission.ou.ous.available']}"  
                                             targetCaptionLabel="#{messages['permission.ou.ous.selected']}"
                                             copyAllControlLabel="#{messages['button.moveAll']}"
                                             copyControlLabel="#{messages['button.move']}"
                                             removeControlLabel="#{messages['button.remove']}"
                                             removeAllControlLabel="#{messages['button.removeAll']}"
                                             topControlLabel="#{messages['button.moveTop']}"
                                             upControlLabel="#{messages['button.moveUp']}"
                                             downControlLabel="#{messages['button.moveDown']}"
                                             bottomControlLabel="#{messages['button.moveBottom']}"
                                             orderControlsVisible="false"
                                             fastOrderControlsVisible="false">                                    
                                             
                                        <rich:column>  
                                            <h:outputLabel value="#{ou.name}" />  
                                        </rich:column>
                                        
                                        <s:convertEntity/>
                                    </rich:listShuttle>
                               </s:decorate>
                          
                               <a4j:commandButton id="editPermissionOUButton" value="#{messages['button.save']}" action="#{ouController.saveOUPermissionsUser}" styleClass="button" />
                               <a4j:commandButton id="cancelButton" value="#{messages['button.cancel']}" reRender="permissionOUUser" styleClass="button" oncomplete="collapseSimpleTogglePanel('permissionOUForm:permissionOU')"/>
                          </rich:simpleTogglePanel>
                     </a4j:form>



      And the link that call this page is:


      <s:button id="editUserButton"
                                          value="#{messages['button.edit']}"
                                          action="#{userController.redirect('update')}"
                                          styleClass="button"
                                          rendered="#{identity.hasPermission(constantsUtil.getEventKey('UPDATE_USER_EVENT_KEY'))}">
                                   <f:param value="#{user.id}" name="userId"/>
                                   <s:conversationPropagation type="join"/>
                               </s:button>



      Thanks

        • 1. Re: Problem with long runnig conversation
          Joshua Jackson Master

          It looks that your problem is on how you begin the conversation.

          • 2. Re: Problem with long runnig conversation
            blabno Master

            And which one is the submit button ? Put logging instructions in the method and see if it really is not invoked. Post your bean code.

            • 3. Re: Problem with long runnig conversation
              Rodolfo Burla Newbie

              Bernard Labno wrote on Aug 27, 2008 10:22:


              And which one is the submit button ? Put logging instructions in the method and see if it really is not invoked. Post your bean code.


              The save button is the submit button. And I put a break point into the method e application did´nt passed there.


              Here is my bean code:


              @Transactional
               public void saveOUPermissionsUser()
               {
                 saveOUPermissionsPermisionHolder(user, listOUsRelatedUser);
               }
              
              @Transactional
              private void saveOUPermissionsPermisionHolder(PermissionHolder permissionHolder,
                        List<OU> listOUsRelatedPermissionHolder)
              {
                 if (permission != null && permissionHolder != null)
                 {
                   if (permissionHolder.getOUPermission() != null)
                   {
                        List<OUPermission> ouPermissionsToRemove = new LinkedList<OUPermission>();
                        for (OUPermission ouPermission : permissionHolder.getOUPermission())
                        {
                            if (permission.equals(ouPermission.getPermission()))
                          {
                             if (!listOUsRelatedPermissionHolder.contains(ouPermission.getOu()))
                             {
                             ouPermissionsToRemove.add(ouPermission);
                             remove(ouPermission);
                             }
                             else
                             {
                             listOUsRelatedPermissionHolder.remove(ouPermission.getOu());
                             }
                          }
                        }
              
                        permissionHolder.getOUPermission().removeAll(ouPermissionsToRemove);
                   }
                   else
                   {
                        permissionHolder.setOUPermission(new LinkedList<OUPermission>());
                   }
              
                   for (OU ou : listOUsRelatedPermissionHolder)
                   {
                        OUPermission ouPermission = new OUPermission();
                        ouPermission.setOu(ou);
                        ouPermission.setPermission(permission);
                        ouPermission.setPermissionHolder(permissionHolder);
                        
                        ouPermission = merge(ouPermission);
                        permissionHolder.getOUPermission().add(ouPermission);
                   }
              
              }
              


              • 4. Re: Problem with long runnig conversation
                Vijay Koppuravuri Newbie

                Try adding this to your update.page.xml to begin the conversation



                <page action="#{conversation.begin}">
                -----
                -----
                -----
                </page>


                • 5. Re: Problem with long runnig conversation
                  Rodolfo Burla Newbie

                  The problem is not the conversation, the problem is the ajaxSingle set to true. When I set it to false, the save works fine, but the reload of the list shuttle doesnt work at the first time.


                  Anybody knows how to correct this problem?


                  Thanks.