2 Replies Latest reply on Aug 24, 2007 5:11 AM by Pete Muir

    To parenthesis or not to parenthesis, that is thy question.

    Mark Spritzler Apprentice

      OK, that subject is just foolish, but anyway, I always seem to get myself stuck behind a problem of my pages.xml navigation not working.

      Now, I have gotten smart after the tenth time this has happened to me to first try to either add or remove the parenthesis in the pages.xml for a <from-action> element.

      But, I have an idea, now it might not completely work, because what if the action takes parameters, then my solution just won't help. But here it is anyway.

      Right now to determine the Navigation it gets all the possible Navigations from a Page stored as a map, and the key is the action Expression, which might or might not have parenthesis and the String passed to navigate might or might not have parenthesis. So I propose the following code for the Pages class.

      
      public boolean navigate(FacesContext context, String actionExpression, String actionOutcomeValue)
       {
       String viewId = getViewId(context);
       if (viewId!=null)
       {
       List<Page> stack = getPageStack(viewId);
       for (int i=stack.size()-1; i>=0; i--)
       {
       Page page = stack.get(i);
       Map<String, Navigation> navigations = page.getNavigations();
       Navigation navigation = navigations.get(actionExpression);
       if (navigation==null)
       {
       navigation = navigations.get(actionExpression+"()");
       if (navigation==null)
       {
       navigation = page.getDefaultNavigation();
       }
       }