Examples of ExternalContext


Examples of javax.faces.context.ExternalContext

    @Override
    protected void initialize(FacesContext context) {
        super.initialize(context);

        ExternalContext external = context.getExternalContext();
        String param = external.getInitParameter(PARAM_DEVELOPMENT);
        this.developmentMode = "true".equals(param);
    }
View Full Code Here

Examples of javax.faces.context.ExternalContext

    this.fileName = fileName;
  }

  public void downloadFile(FacesContext facesContext)
  {
    ExternalContext context = facesContext.getExternalContext();

    if (data == null)
    {
      FacesMessages messages = FacesMessages.instance();

      FacesMessage message = new FacesMessage();
      message.setDetail("MANCA IL FILE");
      message.setSummary("MANCA IL FILE");
      message.setSeverity(FacesMessage.SEVERITY_INFO);

      messages.add(message);
      return;
    }

    HttpServletResponse response = (HttpServletResponse) context.getResponse();
    response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
    response.setContentLength((int) data.length);
    response.setContentType(contentType);

    try
View Full Code Here

Examples of javax.faces.context.ExternalContext

    String contentType = "";
    String fileExt = "";

    try
    {
      ExternalContext context = facesContext.getExternalContext();
      HttpServletResponse response = (HttpServletResponse) context.getResponse();
      OutputStream out = response.getOutputStream();
     
      switch (type)
      {
        case PDF:
View Full Code Here

Examples of javax.faces.context.ExternalContext

   
  private Scope getJsfScope(FacesContext facesContext,
                            String name,
                            boolean isCreate)
  {
    ExternalContext extContext = facesContext.getExternalContext();
    Map<String,Object> sessionMap = extContext.getSessionMap();

    Scope scope = (Scope) sessionMap.get(SESSION_CONVERSATION);
   
    if (scope == null) {
      if (! isCreate)
        return null;
     
      scope = new Scope();
      try {
        sessionMap.put(SESSION_CONVERSATION, scope);
      } catch (Exception e) {
        getSessionScope();
      }
    }
   
    Map<String,String> requestMap = extContext.getRequestParameterMap();
    String cid = (String) requestMap.get("cid");
   
    if (cid == null) {
      cid = (String) facesContext.getViewRoot().getAttributes().get("caucho.cid");
    }
View Full Code Here

Examples of javax.faces.context.ExternalContext

  public void afterPhase(PhaseEvent event)
  {
    final FacesContext context = event.getFacesContext();

    final ExternalContext exContext = context.getExternalContext();

    final Map<String, Object> sessionMap = exContext.getSessionMap();

    Map<String, JsfRequestSnapshot> aidMap
      = (Map<String, JsfRequestSnapshot>) sessionMap.get(
      "caucho.jsf.developer.aid");

    if (aidMap == null) {
      aidMap = new HashMap<String, JsfRequestSnapshot>();

      sessionMap.put("caucho.jsf.developer.aid", aidMap);
    }

    try {
      final UIViewRoot uiViewRoot = context.getViewRoot();

      if (uiViewRoot != null) {
        final String viewId = uiViewRoot.getViewId();
        final String phaseId = event.getPhaseId().toString();

        final ViewRoot viewRoot = (ViewRoot) reflect(context, uiViewRoot);
        viewRoot.setPhase(phaseId);

        //request attributes
        Map<String, Object> requestMap = exContext.getRequestMap();
        Map<String, Bean> requestSnapshot = new HashMap<String, Bean>();

        for (String key : requestMap.keySet()) {
          if (key.startsWith("caucho.") ||
              key.startsWith("com.caucho.") ||
              key.startsWith("javax."))
            continue;

          Bean bean = reflect(requestMap.get(key));

          requestSnapshot.put(key, bean);
        }

        viewRoot.setRequestMap(requestSnapshot);
       

        //session attributes
        Map<String, Bean> sessionSnapshot = new HashMap<String, Bean>();

        for (String key : sessionMap.keySet()) {
          if (key.startsWith("caucho.") ||
              key.startsWith("com.caucho.") ||
              key.startsWith("javax."))
            continue;

          Bean bean = reflect(sessionMap.get(key));

          sessionSnapshot.put(key, bean);
        }

        viewRoot.setSessionMap(sessionSnapshot);

        //application attributes
        Map<String, Object> applicationMap = exContext.getApplicationMap();
        Map<String, Bean> applicationSnapshot = new HashMap<String, Bean>();

        for (String key : applicationMap.keySet()) {
          if (key.startsWith("caucho.") ||
              key.startsWith("com.caucho.") ||
              key.startsWith("javax."))
            continue;

          Bean bean = reflect(applicationMap.get(key));

          applicationSnapshot.put(key, bean);
        }

        viewRoot.setApplicationMap(applicationSnapshot);

        JsfRequestSnapshot snapshot;

        if (PhaseId.RESTORE_VIEW.equals(event.getPhaseId())) {
          snapshot = new JsfRequestSnapshot();

         //headers
          Map<String, String> map = exContext.getRequestHeaderMap();
          snapshot.setHeaderMap(new HashMap<String, String>(map));

          //parameters
          map = exContext.getRequestParameterMap();
          snapshot.setParameterMap(new HashMap<String, String>(map));

          aidMap.put(viewId, snapshot);
        }
        else {
View Full Code Here

Examples of javax.faces.context.ExternalContext

            // Some parts of the following configuration tasks have been implemented
            // by using an ExternalContext. However, that's no problem as long as no
            // one tries to call methods depending on either the ServletRequest or
            // the ServletResponse.
            ExternalContext externalContext = new ServletExternalContextImpl(
                    servletContext, null, null);

            // Parse and validate the web.xml configuration file
            WebXml webXml = WebXml.getWebXml(externalContext);
            if (webXml == null) {
View Full Code Here

Examples of javax.faces.context.ExternalContext

     *
     * @since 2.0
     */
    public String createUniqueId(FacesContext context, String seed)
    {
        ExternalContext extCtx = context.getExternalContext();
        StringBuilder bld = __getSharedStringBuilder();

        Long uniqueIdCounter = (Long) getStateHelper().get(PropertyKeys.uniqueIdCounter);
        uniqueIdCounter = (uniqueIdCounter == null) ? 0 : uniqueIdCounter;
        getStateHelper().put(PropertyKeys.uniqueIdCounter, (uniqueIdCounter+1L));
        // Generate an identifier for a component. The identifier will be prefixed with UNIQUE_ID_PREFIX, and will be unique within this UIViewRoot.
        if(seed==null)
        {
            return extCtx.encodeNamespace(bld.append(UIViewRoot.UNIQUE_ID_PREFIX).append(uniqueIdCounter).toString());   
        }
        // Optionally, a unique seed value can be supplied by component creators which should be included in the generated unique id.
        else
        {
            return extCtx.encodeNamespace(bld.append(UIViewRoot.UNIQUE_ID_PREFIX).append(seed).toString());
        }
    }
View Full Code Here

Examples of javax.faces.context.ExternalContext

     *
     * @since 2.0
     */
    public String createUniqueId(FacesContext context, String seed)
    {
        ExternalContext extCtx = context.getExternalContext();
        StringBuilder bld = __getSharedStringBuilder();

        Long uniqueIdCounter = (Long) getStateHelper().get(PropertyKeys.uniqueIdCounter);
        uniqueIdCounter = (uniqueIdCounter == null) ? 0 : uniqueIdCounter;
        getStateHelper().put(PropertyKeys.uniqueIdCounter, (uniqueIdCounter+1L));
        // Generate an identifier for a component. The identifier will be prefixed with UNIQUE_ID_PREFIX, and will be unique within this UIViewRoot.
        if(seed==null)
        {
            return extCtx.encodeNamespace(bld.append(UNIQUE_ID_PREFIX).append(uniqueIdCounter).toString());   
        }
        // Optionally, a unique seed value can be supplied by component creators which should be included in the generated unique id.
        else
        {
            return extCtx.encodeNamespace(bld.append(UNIQUE_ID_PREFIX).append(seed).toString());
        }
    }
View Full Code Here

Examples of javax.faces.context.ExternalContext


  public void decode(FacesContext facesContext, UIComponent component) {
    super.decode(facesContext, component);
    String clientId = component.getClientId(facesContext);
    ExternalContext externalContext = facesContext.getExternalContext();
    String severity =
        (String) externalContext.getRequestParameterMap().get(clientId + SUBCOMPONENT_SEP + "clientSeverity");
    if (severity != null) {
      externalContext.getRequestMap().put(CLIENT_DEBUG_SEVERITY, severity);
    }
    String lastFocusId =
        (String) externalContext.getRequestParameterMap().get(clientId + SUBCOMPONENT_SEP + LAST_FOCUS_ID);
    if (lastFocusId != null) {
      component.getAttributes().put(LAST_FOCUS_ID, lastFocusId);
    }
    updatePageState(facesContext, component);
  }
View Full Code Here

Examples of javax.faces.context.ExternalContext

        checkForDuplicateIds(facesContext, facesContext.getViewRoot(), new HashSet<String>());

        if (log.isLoggable(Level.FINEST)) log.finest("Processing saveSerializedView - Checked for duplicate Ids");

        ExternalContext externalContext = facesContext.getExternalContext();

        // SerializedView already created before within this request?
        serializedView = externalContext.getRequestMap()
                                                            .get(SERIALIZED_VIEW_REQUEST_ATTR);
        if (serializedView == null)
        {
            if (log.isLoggable(Level.FINEST)) log.finest("Processing saveSerializedView - create new serialized view");

            // first call to saveSerializedView --> create SerializedView
            Object treeStruct = getTreeStructureToSave(facesContext);
            Object compStates = getComponentStateToSave(facesContext);
            serializedView = new Object[] {treeStruct, compStates};
            externalContext.getRequestMap().put(SERIALIZED_VIEW_REQUEST_ATTR,
                                                serializedView);

            if (log.isLoggable(Level.FINEST)) log.finest("Processing saveSerializedView - new serialized view created");
        }
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.