Package javax.faces.application

Examples of javax.faces.application.ViewHandler


        renderScrollHiddenInputIfNecessary(component, facesContext, writer);

        //write state marker at the end of the form
        //Todo: this breaks client-side enabled AJAX components again which are searching for the state
        //we'll need to fix this
        ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
        viewHandler.writeState(facesContext);

        afterFormElementsEnd(facesContext, component);
        writer.endElement(HTML.FORM_ELEM);
    }
View Full Code Here


        // In JSF 1.2, restoreView() will only be called on postback.
        // But in JSF 1.1, it will be called for an initial request too,
        // in which case we must return null in order to fall through
        // to createView()

        ViewHandler outerViewHandler = context.getApplication().getViewHandler();
        String renderKitId = outerViewHandler.calculateRenderKitId(context);

        UIViewRoot viewRoot = createView(context, viewId);
        context.setViewRoot(viewRoot);
        try
        {
View Full Code Here

                //But since the introduction of portlet bridge and the
                //removal of portlet code in myfaces core 2.0, this condition
                //no longer applies
               
                ExternalContext externalContext = facesContext.getExternalContext();
                ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
                String toViewId = navigationCase.getToViewId(facesContext);
                String redirectPath = viewHandler.getRedirectURL(facesContext, toViewId, navigationCase.getParameters(), navigationCase.isIncludeViewParams());
               
                // JSF 2.0 the javadoc of handleNavigation() says something like this
                // "...If the view has changed after an application action, call
                // PartialViewContext.setRenderAll(true)...". The effect is that ajax requests
                // are included on navigation.
                PartialViewContext partialViewContext = facesContext.getPartialViewContext();
                if ( partialViewContext.isPartialRequest() &&
                     !partialViewContext.isRenderAll() &&
                     !facesContext.getViewRoot().getViewId().equals(toViewId))
                {
                    partialViewContext.setRenderAll(true);
                }
               
                // JSF 2.0 Spec call Flash.setRedirect(true) to notify Flash scope and take proper actions
                externalContext.getFlash().setRedirect(true);
                try
                {
                    externalContext.redirect(redirectPath);
                    facesContext.responseComplete();
                }
                catch (IOException e)
                {
                    throw new FacesException(e.getMessage(), e);
                }
            }
            else
            {
                ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
                //create new view
                String newViewId = navigationCase.getToViewId(facesContext);
                // JSF 2.0 the javadoc of handleNavigation() says something like this
                // "...If the view has changed after an application action, call
                // PartialViewContext.setRenderAll(true)...". The effect is that ajax requests
                // are included on navigation.
                PartialViewContext partialViewContext = facesContext.getPartialViewContext();
                if ( partialViewContext.isPartialRequest() &&
                     !partialViewContext.isRenderAll() &&
                     !facesContext.getViewRoot().getViewId().equals(newViewId))
                {
                    partialViewContext.setRenderAll(true);
                }
               
                UIViewRoot viewRoot = viewHandler.createView(facesContext, newViewId);
                facesContext.setViewRoot(viewRoot);
                facesContext.renderResponse();
            }
        }
        else
View Full Code Here

    public static String getOutcomeTargetLinkHref (
            FacesContext facesContext, UIOutcomeTarget component) throws IOException
    {
        String fragment = (String) component.getAttributes().get ("fragment");
        String href = component.getOutcome();
        ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
       
        // The href for an HtmlOutcomeTargetLink is outcome#fragment.
       
        href = ((href == null) ? STR_EMPTY : href.trim());
       
        // Get the correct URL for the outcome.
       
        NavigationHandler nh = facesContext.getApplication().getNavigationHandler();
        if (!(nh instanceof ConfigurableNavigationHandler))
        {
            throw new FacesException("navigation handler must be instance of ConfigurabeNavigationHandler for use h:link or h:button");
        }
        ConfigurableNavigationHandler navigationHandler = (ConfigurableNavigationHandler) nh;
       
        //fromAction is null because there
        NavigationCase navigationCase = navigationHandler.getNavigationCase(facesContext, null, href);

        // when navigation case is null, force the "link" to be rendered as text
        if (navigationCase == null)
        {
            return null;
        }
       
        href = navigationCase.getToViewId(facesContext);
               
        if (fragment != null)
        {
            fragment = fragment.trim();
           
            if (fragment.length() > 0)
            {
                href += "#" + fragment;
            }
        }
       
        Map<String, List<String>> parameters = new HashMap<String,List<String>>();
       
        for (Iterator it = component.getChildren().iterator(); it.hasNext(); )
        {
            UIComponent child = (UIComponent)it.next();
            if (child instanceof UIParameter)
            {
                // check for the disable attribute (since 2.0)
                if (((UIParameter) child).isDisable())
                {
                    // ignore this UIParameter and continue
                    continue;
                }
                String name = ((UIParameter)child).getName();
                Object value = ((UIParameter)child).getValue();
                if (parameters.containsKey(name))
                {
                    parameters.get(name).add(value.toString());
                }
                else
                {
                    ArrayList<String> list = new ArrayList<String>(1);
                    list.add(value.toString());
                    parameters.put(name, list);
                }
            }
        }
       
        if (navigationCase.isIncludeViewParams()) {
            parameters.putAll (navigationCase.getParameters());
        }
       
        // In theory the precedence order to deal with params is this:
        // component parameters, navigation-case parameters, view parameters
        // getBookmarkableURL deal with this details.
        href = viewHandler.getBookmarkableURL(facesContext, href, parameters, navigationCase.isIncludeViewParams() || component.isIncludeViewParams());
               
        return href;
    }
View Full Code Here

      Application application = facesContext.getApplication();
      NavigationHandler navigationHandler = application.getNavigationHandler();
      navigationHandler.handleNavigation(facesContext, null, outcome);

      if (facesContext.getViewRoot() == null) {
        ViewHandler viewHandler = application.getViewHandler();
        String viewId = getFromViewId();
        UIViewRoot view = viewHandler.createView(facesContext, viewId);
        facesContext.setViewRoot(view);
      }

      lifecycle.render(facesContext);
    } finally {
View Full Code Here

        super.encodeEnd(context, component);

        ResponseWriter out = context.getResponseWriter();

        String viewId = context.getViewRoot().getViewId();
        ViewHandler viewHandler = context.getApplication().getViewHandler();
        String actionURL = viewHandler.getActionURL(context, viewId);

        out.startElement(HTML.SCRIPT_ELEM, component);
        out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);

        StringBuffer script = new StringBuffer();
View Full Code Here

        // Derive view identifier
        String viewId = deriveViewId(facesContext);

        Application application = facesContext.getApplication();
        ViewHandler viewHandler = application.getViewHandler();

        //boolean viewCreated = false;
        UIViewRoot viewRoot = viewHandler.restoreView(facesContext, viewId);
        if (viewRoot == null)
        {
            viewRoot = viewHandler.createView(facesContext, viewId);
            viewRoot.setViewId(viewId);
            facesContext.renderResponse();
            //viewCreated = true;
        }
View Full Code Here

        if(isResponseComplete(facesContext, "render", true))
        {
            return;
        }
        Application application = facesContext.getApplication();
        ViewHandler viewHandler = application.getViewHandler();
        try
        {
            viewHandler.renderView(facesContext, facesContext.getViewRoot());
        }
        catch (IOException e)
        {
            throw new FacesException(e.getMessage(), e);
        }
View Full Code Here

                                                  ResponseWriter writer,
                                                  UIComponent component,
                                                  String clientId)
        throws IOException
    {
        ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
        String viewId = facesContext.getViewRoot().getViewId();
        String path = viewHandler.getActionURL(facesContext, viewId);

        StringBuffer hrefBuf = new StringBuffer(path);

        //add clientId parameter for decode
View Full Code Here

        }
        out.endElement(HTML.DIV_ELEM);

        String clientId = component.getClientId(context);
        String viewId = context.getViewRoot().getViewId();
        ViewHandler viewHandler = context.getApplication().getViewHandler();
        String actionURL = viewHandler.getActionURL(context, viewId);

        out.startElement(HTML.SCRIPT_ELEM, null);
        out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
        out.writeText("new Ajax.MyFacesAutocompleter('",null);
        out.writeText(clientId,null);
View Full Code Here

TOP

Related Classes of javax.faces.application.ViewHandler

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.