Kuali Rice Development
  1. Kuali Rice Development
  2. KULRICE-9147

Toggling the show/hide active button on collections causes an exception

    Details

    • Type: Task Task
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.1
    • Fix Version/s: 2.1.4, 2.2.2
    • Component/s: Development
    • Security Level: Public (Public: Anyone can view)
    • Labels:
      None
    • Similar issues:
      KULRICE-9352Show/hide active rows on a collection doesn't work in the inquiry view
      KULRICE-9159Show/hide active rows on a collection doesn't work
      KULRICE-13346Create AFT for Maintenance document toggling active/inactive button.
      KULRICE-4771Show/Hide buttons affect incorrect rows on Inquiry with multiple collections
      KULRICE-3183The show/hide tab buttons on the identityManagementRoleInquiry.do page cause the page to crash when Javascript is disabled
      KULRICE-10641Maintenance document missing show/hide inactive button when collection implements Inactivatable
      KULRICE-9706Create or identify Smoke Test that verifies show/hide inactive lines
      KULRICE-1102bugs with show hide active/inactive
      KULRICE-6414Label for collection field does not show/hide correctly with progressive disclosure or refresh
      KULRICE-3179Document Configuration screen Show/Hide buttons not working correctly
    • Rice Module:
      KRAD
    • Application Requirement:
      Rice
    • KAI Review Status:
      Not Required
    • KTI Review Status:
      Not Required
    • Include in Release Notes?:
      Yes

      Description

      KRAD refactoring of the toggle button action caused the reqComponentId not being passed in the request.

      Steps to recreate:

      • Pull up an existing Term Specification document
      • Click the "show inactive" button

        Issue Links

          Activity

          Hide
          Claus Niesen added a comment -

          fixed exception but toggling doesn't work due some odd lifecycle

          Show
          Claus Niesen added a comment - fixed exception but toggling doesn't work due some odd lifecycle
          Hide
          Jeff Domeyer (Inactive) added a comment -

          The reason this doesn't work is because it is trying to pass the information about whether to show or hide through the view between the controller method invoked and the postControllerHandle of UifControllerHelper.

          The postControllerHandle's prepareViewForRendering will use ComponentFactory.getNewInstanceForRefresh which is going to grab the initial component state of the collection in which the show inactive is set to false. No matter what you do, that's going to be the result.

          What I did to hack around this problem is the following:

          krad.response.js line 138 change:

          jQuery("#" + id).css('display', 'none');
          

          to

          jQuery("#" + id).css('display', 'true');
          

          Otherwise the collections will disappear from lightboxes

          UifActionDefinitions line 145:

          p:additionalSubmitData="showInactiveRecords:true">
          

          to

          p:additionalSubmitData="showInactiveRecords:false">
          

          We actually want to toggle, not always show inactive no matter which button we click on.

          UifGroupDefinitions.xml line 931ish
          The 2 items in the Uif-InactiveItemsActionsGroup need some additional attributes in order to actually refresh the collection properly.

          <bean parent="Uif-ShowInactiveCollectionItemsButton"
                        p:render="@{!#collectionGroup.showInactiveLines and #collectionGroup.renderInactiveToggleButton}"
                        p:additionalSubmitData="showInactiveRecords:true,reqComponentId:@{#component.context['collectionGroup'].id}"
                        p:refreshId="@{#collectionGroup.id}"/>
                  <bean parent="Uif-HideInactiveCollectionItemsButton"
                        p:render="@{#collectionGroup.showInactiveLines and #collectionGroup.renderInactiveToggleButton}"
                        p:additionalSubmitData="showInactiveRecords:false,reqComponentId:@{#component.context['collectionGroup'].id}"
                        p:refreshId="@{#collectionGroup.id}"/>
          
          

          And finally for the hack we need to add the following code
          UifControllerBase - toggleInactiveRecordDisplay(...)

          // update inactive flag on group
                  collectionGroup.setShowInactiveLines(showInactive);
          
          		// This part is to hack into the initial component states which is what
          		// the component refresh is going to use in order to render the
          		// collection group
          		 if(uifForm.getPostedView().getViewIndex().getInitialComponentStates().containsKey(collectionGroup.getBaseId())){
          		 	uifForm.getPostedView().getViewIndex().getInitialComponentStates().remove(collectionGroup.getBaseId());
          		 }
          		 collectionGroup.setBaseId(null);
          		 uifForm.getPostedView().getViewIndex().addInitialComponentStateIfNeeded(collectionGroup);
          		 //End of the hack
                       
                  // run lifecycle and update in view
          //        uifForm.getPostedView().getViewHelperService().performComponentLifecycle(uifForm.getPostedView(), uifForm,
          //                collectionGroup, collectionGroupId);
                  
                  return getUIFModelAndView(uifForm);
          

          This hack skips the view lifecycle part inside the toggle method, as the postControllerHandle will perform the component lifecycle itself. Then extra logic is inserted to for the initial component state of the collection group to have a new copy with the showinactive boolean set to the toggled value. In other words, we're faking out the view to change what it thought was previously rendered.

          This is what is necessary to do as long as a ComponentFactory.getNewInstanceForRefresh is being used in the postControllerHandle.

          Good luck!

          Show
          Jeff Domeyer (Inactive) added a comment - The reason this doesn't work is because it is trying to pass the information about whether to show or hide through the view between the controller method invoked and the postControllerHandle of UifControllerHelper. The postControllerHandle's prepareViewForRendering will use ComponentFactory.getNewInstanceForRefresh which is going to grab the initial component state of the collection in which the show inactive is set to false. No matter what you do, that's going to be the result. What I did to hack around this problem is the following: krad.response.js line 138 change: jQuery( "#" + id).css('display', 'none'); to jQuery( "#" + id).css('display', ' true '); Otherwise the collections will disappear from lightboxes UifActionDefinitions line 145: p:additionalSubmitData= "showInactiveRecords:true" > to p:additionalSubmitData= "showInactiveRecords:false" > We actually want to toggle, not always show inactive no matter which button we click on. UifGroupDefinitions.xml line 931ish The 2 items in the Uif-InactiveItemsActionsGroup need some additional attributes in order to actually refresh the collection properly. <bean parent= "Uif-ShowInactiveCollectionItemsButton" p:render= "@{!#collectionGroup.showInactiveLines and #collectionGroup.renderInactiveToggleButton}" p:additionalSubmitData= "showInactiveRecords:true,reqComponentId:@{#component.context['collectionGroup'].id}" p:refreshId= "@{#collectionGroup.id}" /> <bean parent= "Uif-HideInactiveCollectionItemsButton" p:render= "@{#collectionGroup.showInactiveLines and #collectionGroup.renderInactiveToggleButton}" p:additionalSubmitData= "showInactiveRecords:false,reqComponentId:@{#component.context['collectionGroup'].id}" p:refreshId= "@{#collectionGroup.id}" /> And finally for the hack we need to add the following code UifControllerBase - toggleInactiveRecordDisplay(...) // update inactive flag on group collectionGroup.setShowInactiveLines(showInactive); // This part is to hack into the initial component states which is what // the component refresh is going to use in order to render the // collection group if (uifForm.getPostedView().getViewIndex().getInitialComponentStates().containsKey(collectionGroup.getBaseId())){ uifForm.getPostedView().getViewIndex().getInitialComponentStates().remove(collectionGroup.getBaseId()); } collectionGroup.setBaseId( null ); uifForm.getPostedView().getViewIndex().addInitialComponentStateIfNeeded(collectionGroup); //End of the hack // run lifecycle and update in view // uifForm.getPostedView().getViewHelperService().performComponentLifecycle(uifForm.getPostedView(), uifForm, // collectionGroup, collectionGroupId); return getUIFModelAndView(uifForm); This hack skips the view lifecycle part inside the toggle method, as the postControllerHandle will perform the component lifecycle itself. Then extra logic is inserted to for the initial component state of the collection group to have a new copy with the showinactive boolean set to the toggled value. In other words, we're faking out the view to change what it thought was previously rendered. This is what is necessary to do as long as a ComponentFactory.getNewInstanceForRefresh is being used in the postControllerHandle. Good luck!
          Hide
          Claus Niesen added a comment -

          Thanks, Jeff

          Could you move the comment over to KULRICE-9159 which I specifically created for that issue. There I also documented my findings.

          Show
          Claus Niesen added a comment - Thanks, Jeff Could you move the comment over to KULRICE-9159 which I specifically created for that issue. There I also documented my findings.

            People

            • Assignee:
              Claus Niesen
              Reporter:
              Claus Niesen
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Structure Helper Panel