How do I synchronize multiple ItemsGrid and Path components that bind to different EnterpriseItems beans?

Consider the following scenario: on a single JSP page called contents.jsp, there are two ItemsGrid components and a Path component (a corresponding backing bean exists called Contents.java). The Path component, named path, and one of the ItemsGrid components, named foldersGrid, are both bound to the same EnterpriseItems bean, named folders. This EnterpriseItems bean represents a folder hierarchy within the BusinessObjects Enterprise system that the user can navigate through using path and foldersGrid. Because the two components are both bound to the same EnterpriseItems bean, they are automatically synchronized so that when the user navigates with one component, the other component reflects these changes.

However, the second ItemsGrid component, named reportsList, is bound to a second EnterpriseItems bean called reports, which represents a set of Crystal reports in any given folder. How can reportsList be made to work with the other components on the page? The solution is to synchronize the components in the correct order.

To have the second ItemsGrid component, reportsList, work together with the other components in a meaningful way within the page, the components must be synchronized so that when the user navigates to a certain folder level within foldersList or path, the reportsList displays reports that are present at that same folder level. That is, the parentItemID property of the reports EnterpriseItems bean must be set to the current value of the parentItemID property of the folders bean each time the user clicks a folder in the folders grid or Path component. The result is that the reports grid always shows the same level of information. To enable that co-ordination between components, you must synchronize the data of the components.

To synchronize the components
  1. Open the Contents.java backing bean for editing.
  2. Add the following action event handler method that synchronizes the data between the path component to the reportsList component:
  3. public void synchronizeWithPath() {

        reports.setParentItemID(folders.getParentItemID());

    }

  4. Add the following action event handler method that synchronizes the date between the foldersList component to the reportsList component:
  5. public void synchronizeWithFoldersList() {

        reports.setParentItemID(folders.getParentItemID());

    }

  6. Save and close Contents.java.
  7. Open the contents.jsp page for editing.
  8. Add the following action listener to the path component tag:
  9. actionListener="#{Contents.synchronizeWithPath}"

  10. Add the following action listener to the foldersList component tag:
  11. actionListener="#{Contents.synchronizeWithFoldersList}"

  12. Save and close contents.jsp

Now, when users navigate through their folders using the path or foldersList component, the reportsList component will automatically display any reports in that folder.

Note:    Ensure that the autoHandleEvents attribute of foldersList and path components are set to true (default value).

As you can see, the order of synchronization matters. In our example, we synchronized foldersList to reportsList and path to reportsList. So when foldersList or path is clicked, reportsList is synchronized. However, the opposite is not true. You did not synchronize reportsList to foldersList, therefore actions in reportsList do not affect foldersList. When you decide which component to synchronize, always keep in mind the behavior you wish to accomplish in your application.



Business Objects
http://www.businessobjects.com/
Support services
http://www.businessobjects.com/services/support/