/**
   * Translate the outcome attribute value to the target URL.
   *
   * @param context the current FacesContext
   * @param outcome the value of the outcome attribute
   * @return the target URL of the navigation rule (or the outcome if there's not navigation rule)
   */
  private String determineTargetURL(FacesContext context, String outcome) {
    ConfigurableNavigationHandler cnh =
        (ConfigurableNavigationHandler) context.getApplication().getNavigationHandler();
    NavigationCase navCase = cnh.getNavigationCase(context, null, outcome);
    /*
     * Param Name: javax.faces.PROJECT_STAGE Default Value: The default value is ProjectStage#Production but IDE can set it differently
     * in web.xml Expected Values: Development, Production, SystemTest, UnitTest Since: 2.0
     *
     * If we cannot get an outcome we use an Alert to give a feedback to the Developer if this build is in the Development Stage
     */
    if (navCase == null) {
      if (FacesContext.getCurrentInstance()
          .getApplication()
          .getProjectStage()
          .equals(ProjectStage.Development)) {
        return "alert('WARNING! " + W_NONAVCASE_BUTTON + "');";
      } else {
        return "";
      }
    } // throw new FacesException("The outcome '"+outcome+"' cannot be resolved."); }
    String vId = navCase.getToViewId(context);

    Map<String, List<String>> params = getParams(navCase, this);
    String url;
    url =
        context
            .getApplication()
            .getViewHandler()
            .getBookmarkableURL(
                context, vId, params, isIncludeViewParams() || navCase.isIncludeViewParams());
    return url;
  }
Exemple #2
0
  public String getSectionURI() {
    FacesContext context = FacesContext.getCurrentInstance();

    NavigationHandler handler = context.getApplication().getNavigationHandler();

    if (handler instanceof ConfigurableNavigationHandler) {
      ConfigurableNavigationHandler navigationHandler = (ConfigurableNavigationHandler) handler;

      areaId = getCurrentArea().getId();
      sectionId = getCurrentSection().getId();

      NavigationCase navCase =
          navigationHandler.getNavigationCase(
              context, null, "/bookshop2" + SEPARATOR + areaId + SEPARATOR + sectionId);
      if (navCase != null) return navCase.getToViewId(context);
      return getAreaURI();
    }

    return null;
  }
Exemple #3
0
  public String getAreaURI() {
    FacesContext context = FacesContext.getCurrentInstance();

    NavigationHandler handler = context.getApplication().getNavigationHandler();

    if (handler instanceof ConfigurableNavigationHandler) {
      ConfigurableNavigationHandler navigationHandler = (ConfigurableNavigationHandler) handler;

      areaId = getCurrentArea().getId();
      // sectionId = getCurrentSection().getId();

      NavigationCase navCase =
          navigationHandler.getNavigationCase(
              context, null, "/bookshop2" + SEPARATOR + areaId + SEPARATOR + areaId);
      // NavigationCase navCase = new NavigationCase("/index.xhtml", null, null, null,
      // "/bookshop2/area1/area1.xhtml", null, false, true);
      return navCase.getToViewId(context);
    }

    return null;
  }