Package javax.faces.component

Examples of javax.faces.component.UIOutput


        UINamingContainer compositeComponent2 = (UINamingContainer) facet1.getChildren().get(0);
        Assert.assertNotNull(compositeComponent2);
        UIComponent facet2 = compositeComponent2.getFacet(UIComponent.COMPOSITE_FACET_NAME);
        Assert.assertNotNull(facet2);
        Assert.assertEquals(1,facet2.getChildCount());
        UIOutput targetComp = (UIOutput) facet2.getChildren().get(0);
        UIComponent insertedFacet = targetComp.getFacet("header");
        Assert.assertNotNull(insertedFacet);
    }
View Full Code Here


        {
            Application application = context.getApplication();
           
            // Create a UIOutput instance by passing javax.faces.Output. to
            // Application.createComponent(java.lang.String).
            UIOutput output = (UIOutput) application.createComponent(context, UIOutput.COMPONENT_TYPE, null);
           
            // Get the annotation instance from the class and obtain the values of the name, library, and
            // target attributes.
            String name = annotation.name();
            if (name != null && name.length() > 0)
            {
                name = ELText.parse(getExpressionFactory(),
                                    context.getELContext(), name).toString(context.getELContext());
            }
           
            // Obtain the renderer-type for the resource name by passing name to
            // ResourceHandler.getRendererTypeForResourceName(java.lang.String).
            String rendererType = application.getResourceHandler().getRendererTypeForResourceName(name);
           
            // Call setRendererType on the UIOutput instance, passing the renderer-type.
            output.setRendererType(rendererType);
           
            // Obtain the Map of attributes from the UIOutput component by calling UIComponent.getAttributes().
            Map<String, Object> attributes = output.getAttributes();
           
            // Store the name into the attributes Map under the key "name".
            attributes.put("name", name);
           
            // If library is the empty string, let library be null.
View Full Code Here

        // If this annotation is not present on the class in question, no action must be taken.
        if (annotation != null)
        {
            // Create a UIOutput instance by passing javax.faces.Output. to
            // Application.createComponent(java.lang.String).
            UIOutput output = (UIOutput) createComponent(context, UIOutput.COMPONENT_TYPE, null);

            // Get the annotation instance from the class and obtain the values of the name, library, and
            // target attributes.
            String name = annotation.name();
            if (name != null && name.length() > 0)
            {
                name = ELText.parse(getExpressionFactory(),
                                    context.getELContext(), name).toString(context.getELContext());
            }

            // Obtain the renderer-type for the resource name by passing name to
            // ResourceHandler.getRendererTypeForResourceName(java.lang.String).
            // (note that we can not use this.getResourceHandler(), because the Application might be wrapped)
            String rendererType = context.getApplication().getResourceHandler().getRendererTypeForResourceName(name);

            // Call setRendererType on the UIOutput instance, passing the renderer-type.
            output.setRendererType(rendererType);

            // Obtain the Map of attributes from the UIOutput component by calling UIComponent.getAttributes().
            Map<String, Object> attributes = output.getAttributes();

            // Store the name into the attributes Map under the key "name".
            attributes.put("name", name);

            // If library is the empty string, let library be null.
View Full Code Here

  public static boolean isHoverEnabled(UIComponent component) {
    return ComponentUtil.getBooleanAttribute(component, ATTR_HOVER);
  }

  public static UIOutput getFirstNonGraphicChild(UIComponent component) {
    UIOutput output = null;
    for (Object o : component.getChildren()) {
      UIComponent uiComponent = (UIComponent) o;
      if ((uiComponent instanceof UIOutput)
          && !(uiComponent instanceof UIGraphic)) {
        output = (UIOutput) uiComponent;
View Full Code Here

     * and it is possible that something was written to the Response direct.
     * So is is necessary that the content of the wrapped response is added to the componenttree.
     * @return UIComponent or null
     */
    protected UIComponent createVerbatimComponentFromBodyContent() {
        UIOutput component = (UIOutput) super.createVerbatimComponentFromBodyContent();
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Object response = facesContext.getExternalContext().getResponse();
        String wrappedOutput;

        if (response instanceof ViewResponseWrapper)
        {
            ViewResponseWrapper wrappedResponse = (ViewResponseWrapper) response;
            wrappedOutput = wrappedResponse.toString();
            if (wrappedOutput.length() > 0)
            {
                String componentvalue = null;
                if (component != null)
                {
                    //save the Value of the Bodycontent
                  componentvalue = (String) component.getValue();
                }
                component = super.createVerbatimComponent();
                if (componentvalue != null)
                {
                    component.setValue(wrappedOutput + componentvalue);
                }
                else
                {
                    component.setValue(wrappedOutput);
                }
                wrappedResponse.reset();
            }
        }
        return component;
View Full Code Here

    /**
     * Creates a UIComponent from the BodyContent
     */
    protected UIComponent createVerbatimComponentFromBodyContent()
    {
        UIOutput verbatimComp = null;

        if (bodyContent != null)
        {
            String strContent = bodyContent.getString();

            if (strContent != null)
            {
                String trimmedContent = strContent.trim();
                if (trimmedContent.length() > 0 && !isComment(strContent))
                {
                    verbatimComp = createVerbatimComponent();
                    verbatimComp.setValue(strContent);
                }
            }

            bodyContent.clearBody();
        }
View Full Code Here

     * <p><code>id</code> is
     * <code>FacesContext.getViewRoot().createUniqueId()</code></p>
     */
    protected UIOutput createVerbatimComponent()
    {
        UIOutput verbatimComp = (UIOutput) getFacesContext().getApplication()
                .createComponent("javax.faces.HtmlOutputText");
        verbatimComp.setTransient(true);
        verbatimComp.getAttributes().put("escape", Boolean.FALSE);
        verbatimComp.setId(getFacesContext().getViewRoot().createUniqueId());

        return verbatimComp;
    }
View Full Code Here

        locale = facesContext.getViewRoot().getLocale();
       
        executeBeforeRender(facesContext);
        executeBuildViewCycle(facesContext);
       
        UIOutput testjs1_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs");
        Assert.assertNotNull(testjs1_1);
        testjs1_1.getAttributes().put("param1", "value1");
       
        List<UIComponent> crlist = facesContext.getViewRoot().getComponentResources(facesContext, "head");
        Assert.assertEquals(2, crlist.size());
        for(UIComponent comp : crlist)
        {
            comp.getAttributes().put("param2", "value2");
        }
       
        executeViewHandlerRender(facesContext);
        executeAfterRender(facesContext);
       
        tearDownRequest();

        setupRequest("/staticPageNoForm2.xhtml");
        processLifecycleExecute();
       
        executeBeforeRender(facesContext);
        executeBuildViewCycle(facesContext);
       
        Assert.assertTrue(facesContext.getViewRoot().getChildCount() > 0);
       
        UIOutput testjs2_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs");
        Assert.assertNotNull(testjs2_1);
        // The state of the component should not be transferred.
        Assert.assertNull(testjs2_1.getAttributes().get("param1"));
       
        List<UIComponent> crlist2 = facesContext.getViewRoot().getComponentResources(facesContext, "head");
        Assert.assertEquals(2, crlist2.size());  
        for(UIComponent comp : crlist)
        {
View Full Code Here

        locale = facesContext.getViewRoot().getLocale();
        executeBeforeRender(facesContext);
        executeBuildViewCycle(facesContext);
       
        // Add a component in order to trigger a dynamic update
        UIOutput testComponent = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);
        testComponent.setId("testId");
        testComponent.setValue("Some Text");
        UIForm form = (UIForm) facesContext.getViewRoot().findComponent("mainForm");
        form.getChildren().add(testComponent);
       
        executeViewHandlerRender(facesContext);
        executeAfterRender(facesContext);
       
        UIViewRoot root = new UIViewRoot();
        root.setLocale(locale);
        root.setRenderKitId("HTML_BASIC");
        root.setViewId("/staticPage.xhtml");
       
        ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
        ViewPool viewPool = processor.getViewPool(facesContext, root);
        ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
        Assert.assertNotNull(entry);
        Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
       
        //Check the component was removed
        UIForm form2 = (UIForm) entry.getViewRoot().findComponent("mainForm");
        Assert.assertNotNull(form2);
        UIOutput testComponent2 = (UIOutput) form2.findComponent("testId");
        Assert.assertNull(testComponent2);
       
        tearDownRequest();
    }
View Full Code Here

        locale = facesContext.getViewRoot().getLocale();
        executeBeforeRender(facesContext);
        executeBuildViewCycle(facesContext);
       
        // Add a component in order to trigger a dynamic update
        UIOutput testComponent = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);
        testComponent.setId("testId");
        testComponent.setValue("Some Text");
        UIForm form = (UIForm) facesContext.getViewRoot().findComponent("mainForm");
        form.getChildren().add(testComponent);
       
        executeViewHandlerRender(facesContext);
        executeAfterRender(facesContext);
       
        UIViewRoot root = new UIViewRoot();
        root.setLocale(locale);
        root.setRenderKitId("HTML_BASIC");
        root.setViewId("/staticPage.xhtml");
       
        ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
        ViewPool viewPool = processor.getViewPool(facesContext, root);
        ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
        Assert.assertNotNull(entry);
        Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
       
        //Check the component was removed
        UIForm form2 = (UIForm) entry.getViewRoot().findComponent("mainForm");
        Assert.assertNotNull(form2);
        UIOutput testComponent2 = (UIOutput) form2.findComponent("testId");
        Assert.assertNull(testComponent2);
       
        tearDownRequest();
    }
View Full Code Here

TOP

Related Classes of javax.faces.component.UIOutput

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.