Click
  1. Click
  2. CLK-39

Non-menu pages associated with a menu

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None

      Description

      The existing menu component allows hierarchical support of menus. A top menu can have several submenus etc. However, if you have a menu node to view a 'customerList' page and a link from that page takes the user to a page (editCustomer) that is not a menu node, then any mechanism that is in place to keep the menu hierarchy open fails, since the 'selected' menu node is no longer selected. What is required is that the 'customerList' menu node needs to know what sub pages can be displayed from 'customerList'.

      A suggested solution - allow a comma-separated list of pages to be added to a node, and change the select method to determine if the resourcePath is part of this comma-separated list.

      Eg: menu.xml
      <menu label="Management" path="customerList.htm">
      <menu label="Customers" path="customerList.htm" title="Customers"
      pages="/editCustomer.htm,deleteCustomer.htm,viewCustomer.htm"/>
      </menu>

      And, in Menu.java:

      public void select(Context context) {
      String pageToView = context.getResourcePath();
      if (pages.contains(pageToView))

      { // need to select the menu item selected = true; }

      else {
      String path = getPath();
      if (path != null)

      { path = path.startsWith("/") ? path : "/" + path; selected = path.equals(context.getResourcePath()); }

      else

      { selected = false; }

      }
      for (int i = 0; i < getChildren().size(); i++) {
      Menu menu = (Menu) getChildren().get;
      menu.select(context);
      if (menu.isSelected())

      { selected = true; }

      }
      }

      Obviously the page list needs to be parsed in the getRootMenu method into a 'pages' ArrayList, similar to the 'roles' code,

        Activity

        Hide
        Malcolm Edgar added a comment -

        Changed my mind, removed ContextAware interface and made Menu implement Control interface.

        Show
        Malcolm Edgar added a comment - Changed my mind, removed ContextAware interface and made Menu implement Control interface.
        Hide
        Malcolm Edgar added a comment -

        Hi Geoff,

        I have refactored the Menu component to use ContextAware interface to enable easier Page subclassing, ie you can define a Menu component in a common Page constructor. For example:

        public class BorderedPage extends Page {
        public BorderedPage

        { addModel("rootMenu", new Menu()); }

        }

        The old style static initializer is still supported.

        regards Malcolm

        Show
        Malcolm Edgar added a comment - Hi Geoff, I have refactored the Menu component to use ContextAware interface to enable easier Page subclassing, ie you can define a Menu component in a common Page constructor. For example: public class BorderedPage extends Page { public BorderedPage { addModel("rootMenu", new Menu()); } } The old style static initializer is still supported. regards Malcolm
        Hide
        Geoff Hopson added a comment -

        The code that is currently in CVS works fine. Thanks.

        Show
        Geoff Hopson added a comment - The code that is currently in CVS works fine. Thanks.
        Hide
        Malcolm Edgar added a comment -

        Hi Phil,

        I have checked in your changes. Could you test these, to make sure I haven't stuffed anything up.

        regards Malcolm

        Show
        Malcolm Edgar added a comment - Hi Phil, I have checked in your changes. Could you test these, to make sure I haven't stuffed anything up. regards Malcolm

          People

          • Assignee:
            Malcolm Edgar
            Reporter:
            Geoff Hopson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development