javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2516

Redirecting with view params via navigation API tranfers only first param

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Duplicate
    • Affects Version/s: 2.1.13
    • Fix Version/s: 2.1.19, 2.2.0-m10
    • Component/s: navigation
    • Labels:
      None

      Description

      Hi everybody,

      i have two views with the same <f:viewParam name="..."/>'s defined (without bean reference). Now i try to navigate from one view to the other via navigation API preserving the parameters (includeViewParams flag set). But the generated URL only contains the first param, so after redirect all view params are gone but the first. Here is some code:

      public String navigateTo(String view) {
      FacesContext ctx = FacesContext.getCurrentInstance();
      String viewId = ctx.getViewRoot().getViewId();
      Application app = ctx.getApplication();
      SeamNavigationHandler handler = (SeamNavigationHandler) app.getNavigationHandler();
      Map<String, Set<NavigationCase>> navCases = handler.getNavigationCases();
      NavigationCase navCase = new NavigationCase(viewId, null, "success", null, view, null, true, true);
      Set<NavigationCase> navCaseSet = new HashSet<NavigationCase>();
      navCaseSet.add(navCase);
      navCases.put(navCase.getFromViewId(), navCaseSet);
      return "success";
      }

      While debugging down i found the following method in com.sun.faces.application.view.MultiViewHandler which is used to copy view parameter values from source to destination view (please see also method MultiViewHandler.addViewParameters):

      private static String getStringValueToTransfer(FacesContext context, UIViewParameter param, Collection<UIViewParameter> viewParams) {
      if (viewParams != null && !viewParams.isEmpty()) {
      for (UIViewParameter candidate : viewParams) {
      if ((null != candidate.getName() && null != param.getName()) &&
      candidate.getName().equals(param.getName()))

      { return candidate.getStringValue(context); }

      else

      { return param.getStringValue(context); }

      }
      }
      return null;
      }

      It seems pretty clear to me now why only the first param is transfered... It should only return param.getStringValue(context) if the name is not found in ALL iterations, right?
      Or is it somewhat intended?

      Thanks, best regards
      Flo

        Issue Links

          Activity

          Hide
          Manfred Riem added a comment -

          Can you please attach an example application (with sources) that demonstrates the problem?

          Show
          Manfred Riem added a comment - Can you please attach an example application (with sources) that demonstrates the problem?
          Hide
          Manfred Riem added a comment -

          Can you verify if it is still an issue with the latest 2.1 release?

          Show
          Manfred Riem added a comment - Can you verify if it is still an issue with the latest 2.1 release?
          Hide
          Manfred Riem added a comment -

          Lowering priority because of no response

          Show
          Manfred Riem added a comment - Lowering priority because of no response

            People

            • Assignee:
              Manfred Riem
              Reporter:
              flopsi
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: