Пример #1
0
  /**
   * 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;
  }
Пример #2
0
 public void checkRoles(ComponentSystemEvent event) {
   if (getUserAuth() == null
       && JSFUtils.getUserName() != null
       && !JSFUtils.getUserName().isEmpty()) {
     userAuth = userRepository.findByUsername(JSFUtils.getUserName());
     setUserAuth(userAuth);
     logOperationsController.save("LOGIN", JSFUtils.getUserName(), "LOGIN");
   }
   String acl = "" + event.getComponent().getAttributes().get("roles");
   for (String a : acl.split(",")) {
     if ("ANY".equalsIgnoreCase(a)) {
       if (JSFUtils.getUserName() != null && JSFUtils.getUserName().length() > 0) {
         return;
       }
     }
     if (isInRole(a.trim())) {
       return;
     }
   }
   try {
     logger.info(acl + " - non consentito!");
     FacesContext context = FacesContext.getCurrentInstance();
     ConfigurableNavigationHandler handler =
         (ConfigurableNavigationHandler) context.getApplication().getNavigationHandler();
     handler.performNavigation("administration");
   } catch (Exception e) {
     e.printStackTrace();
     // Se siamo qui il redirect è fallito.
     // A questo punto, piuttosto che lasciare andare l'utente dove
     // non deve.. runtime exception!
     throw new RuntimeException("Accesso non consentito");
   }
 }
Пример #3
0
  public void onRowDblselect(SelectEvent event) {
    FacesContext context = FacesContext.getCurrentInstance();
    ConfigurableNavigationHandler handler =
        (ConfigurableNavigationHandler) context.getApplication().getNavigationHandler();
    Flash flash = context.getExternalContext().getFlash();
    flash.put("selectedCar", (StockProductoTiendaOrigen) event.getObject());

    handler.performNavigation("carDetail");
  }
Пример #4
0
  public void checkLogin(ComponentSystemEvent event) {

    System.out.println("checando o login");

    if (!loggedIn) {
      FacesContext context = FacesContext.getCurrentInstance();

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

      handler.performNavigation("login");
    }
  }
Пример #5
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;
  }
Пример #6
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;
  }
Пример #7
0
 public void modif() {
   FacesContext fc = FacesContext.getCurrentInstance();
   ConfigurableNavigationHandler nav =
       (ConfigurableNavigationHandler) fc.getApplication().getNavigationHandler();
   nav.performNavigation("modif_four");
 }