3 Replies Latest reply on Apr 6, 2013 2:04 PM by Sham HC

    Pathfield references in custom multifield not getting updated on page move or rename

    T. Devine

      We're using a custom multified to store link title, link path (pathfield) as well as a checkbox as to wether the link should open in a new browser window.  CQ 5.4 (we're in the process of moving to 5.5 and assume it works the same) ends up storing this information in a delimited string[].  Not only does this cause issues when an author uses the delimeter character in the link name, but more importantly it seems as though CQ doesn't update the pathfield reference if the target page is moved (or renamed.) 

       

      Is there anyway to influence the way multifield is storing this data in the JCR so that it automatically updates references when the target page is moved?

       

      Thanks,

      Tim

        • 1. Re: Pathfield references in custom multifield not getting updated on page move or rename
          pchamoun Level 1

          Create an Observation Listener bundle component that monitors changes using Event.PROPERTY_CHANGED and then do the update based on the change. It could be something like the following:

           

          Add the event listener in the activate function of the component

          session = repository.loginAdministrative(null);

          observationManager = session.getWorkspace().getObservationManager(); 

          observationManager.addEventListener(this, Event.PROPERTY_REMOVED | Event.PROPERTY_CHANGED, "/", true, null,  null, true);

           

          Then in the onEvent() function you can handle the event change or remove. If there is a change then you make a search in the pathfileds to see if that link exists.

          public void onEvent(EventIterator it) {

               while (it.hasNext()) {

                    Event event = it.nextEvent();

                    // Here you can pull the transaction from the event like info about property and so on

                    Property property = session.getProperty(event.getPath());

                      ...

               }

          }

          • 2. Re: Pathfield references in custom multifield not getting updated on page move or rename
            T. Devine Level 1

            Clarifying to make sure I understand what you are suggesting.  The actual change is the moving or renaming of the page being reference by a pathfield within the multifield component.  So no data in the component itself is changing. Pages that it's referencing are what are changing.

             

            Generic example of format of property in JCR

             

            String[] = Link Name||Link Path (pathfield),Link2 Name||Link2 Path (pathfield)

             

            Tangible example with test data

             

            String[] = Test Link 1||/content/company/pageA,Test Link 2||/content/company/pageB

             

            So let's say someone moves /content/company/PageB to /content/company/PageC.  That's where we are running into the issue.  The property above still has /content/company/PageB which is now out of date.

             

            So are you saying create an event listener on the change of a page path...and when that happens search the repository for references to the old name (updating them with the new name)?

            • 3. Re: Pathfield references in custom multifield not getting updated on page move or rename
              Sham HC Level 7

              Hi Devine,

               

              Ya, I believe that was the suggestion. Operation would be expensive but that's the option.

               

              Thanks,

              Sham