Package com.liferay.faces.portal.context

Examples of com.liferay.faces.portal.context.LiferayFacesContext


  public void validate(FacesContext facesContext, UIComponent uiComponent, Object value) throws ValidatorException {

    if (value != null) {

      LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();

      try {
        PortletRequest portletRequest = liferayFacesContext.getPortletRequest();
        String userCaptchaTextValue = value.toString();
        String correctCaptchaTextValue = (String) liferayFacesContext.getSessionAttribute(
            WEB_KEYS_CAPTCHA_TEXT);

        CaptchaPortletRequest captchaPortletRequest = new CaptchaPortletRequest(portletRequest,
            userCaptchaTextValue);

        // The CaptchaUtil.check(PortletRequest) method will ultimately call
        // portletRequest.getParameter("captchaText") and so we have to pass a CaptchaPortletRequest to handle
        // that. This is because the string "captchaText" is hard-coded in the liferay-ui:captcha JSP.
        CaptchaUtil.check(captchaPortletRequest);

        // Liferay Captcha implementations like SimpleCaptchaUtil will remove the "CAPTCHA_TEXT" session
        // attribute when calling the Capatcha.check(PortletRequest) method. But this will cause a problem
        // if we're using an Ajaxified input field. As a workaround, set the value of the attribute again.
        liferayFacesContext.setSessionAttribute(WEB_KEYS_CAPTCHA_TEXT, correctCaptchaTextValue);
      }
      catch (CaptchaTextException e) {
        String key = "text-verification-failed";
        String summary = liferayFacesContext.getMessage(key);
        FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, summary, summary);
        throw new ValidatorException(facesMessage);
      }
      catch (CaptchaMaxChallengesException e) {
        String key = "maximum-number-of-captcha-attempts-exceeded";
        String summary = liferayFacesContext.getMessage(key);
        FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, summary, summary);
        throw new ValidatorException(facesMessage);
      }
      catch (Exception e) {
        logger.error(e);

        String key = "an-unexpected-error-occurred";
        String summary = liferayFacesContext.getMessage(key);
        FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, summary, summary);
        throw new ValidatorException(facesMessage);
      }
    }
  }
View Full Code Here


      // Ensure that scripts are rendered at the bottom of the page.
      String scripts = portalTagOutput.getScripts();

      if (scripts != null) {
        LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
        liferayFacesContext.getJavaScriptMap().put(uiComponent.getClientId(), scripts);
      }

      // Encode the children markup.
      String childrenMarkup = bufferedChildrenMarkupWriter.toString();
View Full Code Here

  }

  public UserLazyDataModel getDataModel() {

    if (userDataModel == null) {
      LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
      int rowsPerPage = liferayFacesContext.getPortletPreferenceAsInt("rowsPerPage",
          SearchContainer.DEFAULT_DELTA);
      userDataModel = new UserLazyDataModel(liferayFacesContext.getCompanyId(), rowsPerPage);
    }

    return userDataModel;
  }
View Full Code Here

  }

  public List<SelectItem> getStatusSelectItems() {

    if (statusSelectItems == null) {
      LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
      statusSelectItems = new ArrayList<SelectItem>();
      statusSelectItems.add(new SelectItem(WorkflowConstants.STATUS_ANY,
          liferayFacesContext.getMessage("any-status")));
      statusSelectItems.add(new SelectItem(WorkflowConstants.STATUS_APPROVED,
          liferayFacesContext.getMessage("active")));
      statusSelectItems.add(new SelectItem(WorkflowConstants.STATUS_INACTIVE,
          liferayFacesContext.getMessage("inactive")));
    }

    return statusSelectItems;
  }
View Full Code Here

      }
    }
    catch (Exception e) {
      logger.error(e);

      LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
      liferayFacesContext.addGlobalUnexpectedErrorMessage();
    }
  }
View Full Code Here

        uploadedFileWrapper.getAbsolutePath());
    }
    catch (Exception e) {
      logger.error(e);

      LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
      liferayFacesContext.addGlobalUnexpectedErrorMessage();
    }
  }
View Full Code Here

      }
    }
    catch (Exception e) {
      logger.error(e.getMessage(), e);

      LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
      liferayFacesContext.addGlobalUnexpectedErrorMessage();
    }

    usersViewBean.setFormRendered(false);
    usersModelBean.forceListReload();
  }
View Full Code Here

      usersViewBean.setFormRendered(true);
    }
    catch (Exception e) {
      logger.error(e.getMessage(), e);

      LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
      liferayFacesContext.addGlobalUnexpectedErrorMessage();
    }
  }
View Full Code Here

      // Ensure that scripts are rendered at the bottom of the page.
      String scripts = portalTagOutput.getScripts();

      if (scripts != null) {
        LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
        liferayFacesContext.getJavaScriptMap().put(uiComponent.getClientId(), scripts);
      }
    }
    catch (JspException e) {
      throw new IOException(e);
    }
View Full Code Here

    return null;
  }

  @Override
  public String getRequestPath() {
    LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
    String portalURL = liferayFacesContext.getPortalURL();

    return portalURL + resourceName;
  }
View Full Code Here

TOP

Related Classes of com.liferay.faces.portal.context.LiferayFacesContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.