Package org.apache.shale.clay.config.beans

Examples of org.apache.shale.clay.config.beans.AttributeBean


        String description = bean.getDescription();
        assertNotNull(description);
       
        assertTrue(description.startsWith("This component builds a sub component tree and attaches"));
       
        AttributeBean attr = bean.getAttribute("managedBeanName");
        assertNotNull(attr);
       
        description = attr.getDescription();
        assertEquals("A symbol that is used to alias the bound backing bean.", description);

       
        bean = standardConfigBean.getElement("baseHtml");
        assertNotNull(bean);
View Full Code Here


        assertNotNull(bean);
       
        String description = bean.getDescription();
        assertNull(description);
              
        AttributeBean attr = bean.getAttribute("managedBeanName");
        assertNotNull(attr);
       
        description = attr.getDescription();
        assertNull(description);

        bean = standardConfigBean.getElement("baseHtml");
        assertNotNull(bean);
       
View Full Code Here

        // find the config bean definition in the commons XML config file
        ComponentBean configBean = standardConfigBean.getElement("acme:city");
        assertNotNull("acme:city exists", configBean);
        assertEquals("id", "city", configBean.getId());
       
        AttributeBean size = configBean.getAttribute("size");
        assertNotNull("size", size);
        assertEquals("size", "20", size.getValue());
       
        AttributeBean value = configBean.getAttribute("value");
        assertNotNull("value", value);
        assertEquals("value", "#{@managed-bean-name.city}", value.getValue());
       
        AttributeBean maxlength = configBean.getAttribute("maxlength");
        assertNotNull("maxlength", maxlength);
        assertEquals("maxlength", "30", maxlength.getValue());
       
        AttributeBean required = configBean.getAttribute("required");
        assertNotNull("required", required);
        assertEquals("required", "true", required.getValue());
      

        // load a template that points/extends the acme:city widget
        ComponentBean templateRoot = htmlTemplateConfigBean.getElement("/org/apache/shale/clay/config/altns.html");
        assertNotNull("/org/apache/shale/clay/config/altns.html",  templateRoot);
       
        // config bean after extend by the html template
        ComponentBean cityConfigBean = findForId(configBean.getId(), templateRoot);
        assertNotNull("city from html template", cityConfigBean);
       
        // inherit from acme:city
        assertEquals("id", "city", cityConfigBean.getId());
       
        // html override
        size = cityConfigBean.getAttribute("size");
        assertNotNull("size", size);
        assertEquals("size", "10", size.getValue());
       
        // inherit from acme:city
        value = cityConfigBean.getAttribute("value");
        assertNotNull("value", value);
        assertEquals("value", "#{@managed-bean-name.city}", value.getValue());
       
        // html override
        maxlength = cityConfigBean.getAttribute("maxlength");
        assertNotNull("maxlength", maxlength);
        assertEquals("maxlength", "100", maxlength.getValue());
       
        // html override
        required = cityConfigBean.getAttribute("required");
        assertNotNull("required", required);
        assertEquals("required", "false", required.getValue());
       
        // just because we can
        chainsListener.contextDestroyed(servletContextEvent);
    }
View Full Code Here

     * @param root parent config bean
     */
    protected void encodeBegin(Node node, ElementBean target, ComponentBean root) {
        super.encodeBegin(node, target, root);

        AttributeBean valueAttr = target.getAttribute("value");
        StringBuffer comment = new StringBuffer(valueAttr.getValue());
        captureComment(node, comment);
        valueAttr.setValue(comment.toString());
        valueAttr.setBindingType(AttributeBean.BINDING_TYPE_NONE);

    }
View Full Code Here

     */
    protected void encodeBegin(Node node, ElementBean target, ComponentBean root) {
        super.encodeBegin(node, target, root);

        if (node.getName().equals("directive.include")) {
            AttributeBean attr = target.getAttribute("clayJsfid");
            SymbolBean symbol = target.getSymbol("file");
            if (symbol != null && attr != null) {
                createAttribute(attr, "@file", target);
            }
        } else if (node.getName().equals("include")) {
            AttributeBean attr = target.getAttribute("clayJsfid");
            SymbolBean symbol = target.getSymbol("@page");
            if (symbol != null && attr != null) {
                createAttribute(attr, "@page", target);
            }
            Iterator ai = node.getChildren().iterator();
View Full Code Here

                String name = (String) child.getAttributes().get("name");
                String value = (String) child.getAttributes().get("value");
                String bindingType = (String) child.getAttributes().get("bindingType");

                AttributeBean attr = target.getAttribute(name);
                if (attr != null) {
                    createAttribute(attr, value, target);
                } else {
                    attr = new AttributeBean();
                    attr.setName(name);
                    attr.setValue(value);
                    attr.setBindingType(bindingType);
                    target.addAttribute(attr);
                }
            }
        }
    }
View Full Code Here

        javax.faces.component.html.HtmlOutputText child = (javax.faces.component.html.HtmlOutputText)
                                facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
       assertNotNull("javax.faces.HtmlOutputText", child);
      
      
       AttributeBean attr = new AttributeBean();
       attr.setName("value");
       attr.setBindingType(AttributeBean.BINDING_TYPE_NONE);
       attr.setValue("10");
      
       ComponentBean displayElement = new ComponentBean();
       displayElement.setJsfid("inputText");
       displayElement.setComponentType("javax.faces.HtmlOutputText");
       displayElement.setId("testId");
       displayElement.addAttribute(attr);
      
       assertNotNull("attribute case insensitive", displayElement.getAttribute("VaLue"));
      
       ClayContext clayContext = new ClayContext();
       clayContext.setFacesContext(facesContext);
       clayContext.setChild(child);
       clayContext.setAttribute(attr);
       clayContext.setDisplayElement(displayElement);
             
       Command command = new PropertyValueCommand();
       boolean isFinal = command.execute(clayContext);
       assertEquals("command finished", true, isFinal);      
       assertEquals("value = 10", child.getValue(), "10");

      
       child = (javax.faces.component.html.HtmlOutputText)
                               facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
       assertNotNull("javax.faces.HtmlOutputText", child);
       clayContext.setChild(child);
      
       servletContext.setAttribute("goodYear", "1969");
       attr.setBindingType(AttributeBean.BINDING_TYPE_VALUE);
       attr.setValue("#{goodYear}");

       isFinal = command.execute(clayContext);
       assertEquals("command finished", true, isFinal);      
       assertEquals("value = 1969", "1969", child.getValue());
      
       child = (javax.faces.component.html.HtmlOutputText)
                             facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
       assertNotNull("javax.faces.HtmlOutputText", child);
       clayContext.setChild(child);
      
       servletContext.setAttribute("ping", "pong");
       attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
       attr.setValue("#{ping}");

       isFinal = command.execute(clayContext);
       assertEquals("command finished", true, isFinal);      
       assertEquals("value = pong", child.getValue(), "pong");


       child = (javax.faces.component.html.HtmlOutputText)
                               facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
       assertNotNull("javax.faces.HtmlOutputText", child);
       clayContext.setChild(child);
      
       attr.setBindingType(AttributeBean.BINDING_TYPE_NONE);
       attr.setValue("#{forManfred}");

       isFinal = command.execute(clayContext);
       assertEquals("command finished", true, isFinal);      
       assertEquals("value = #{forManfred}", "#{forManfred}", child.getValue());
View Full Code Here

           javax.faces.component.html.HtmlOutputText child = (javax.faces.component.html.HtmlOutputText)
                              facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
           assertNotNull("javax.faces.HtmlOutputText", child);
          
          
           AttributeBean attr = new AttributeBean();
           attr.setName("value");
           attr.setBindingType(AttributeBean.BINDING_TYPE_NONE);
           attr.setValue("@value")//symbolic attribute
                     
           ComponentBean displayElement = new ComponentBean();
           displayElement.setJsfid("inputText");
           displayElement.setComponentType("javax.faces.HtmlOutputText");
           displayElement.setId("testId");
           displayElement.addAttribute(attr);
           displayElement.addSymbol(createSymbol("@value", "10"));
                     
           ClayContext clayContext = new ClayContext();
           clayContext.setFacesContext(facesContext);
           clayContext.setChild(child);
           clayContext.setAttribute(attr);
           clayContext.setDisplayElement(displayElement);
           clayContext.setSymbols(displayElement.getSymbols());
          
           Command command = new PropertyValueCommand();
           boolean isFinal = command.execute(clayContext);
           assertEquals("command finished", true, isFinal);      
           assertEquals("value = 10", "10", child.getValue());

          
           // test a symbol value of an el value
           child = (javax.faces.component.html.HtmlOutputText)
                        facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
           assertNotNull("javax.faces.HtmlOutputText", child);

           displayElement.addSymbol(createSymbol("@value", "#{value}"));
           attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
           servletContext.setAttribute("value", "10");
         
           clayContext.setFacesContext(facesContext);
           clayContext.setChild(child);
           clayContext.setAttribute(attr);
           clayContext.setDisplayElement(displayElement);
           clayContext.setSymbols(displayElement.getSymbols());
          
           isFinal = command.execute(clayContext);
           assertEquals("command finished", true, isFinal);      
           assertEquals("value = 10", "10", child.getValue());

          
           // test a symbol value with a null value symbol replacement
           child = (javax.faces.component.html.HtmlOutputText)
                 facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
           assertNotNull("javax.faces.HtmlOutputText", child);

           displayElement.addSymbol(createSymbol("@value", null));
           attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
         
           clayContext.setFacesContext(facesContext);
           clayContext.setChild(child);
           clayContext.setAttribute(attr);
           clayContext.setDisplayElement(displayElement);
           clayContext.setSymbols(displayElement.getSymbols());
          
           isFinal = command.execute(clayContext);
           assertEquals("command finished", true, isFinal);      
           assertEquals("value = null", null, child.getValue());


           // test a symbol value with an empty String value. 
           // this will evaluate to null since it is a symbol replacement.
           child = (javax.faces.component.html.HtmlOutputText)
                     facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
           assertNotNull("javax.faces.HtmlOutputText", child);

           displayElement.addSymbol(createSymbol("@value", ""));
           attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
         
           clayContext.setFacesContext(facesContext);
           clayContext.setChild(child);
           clayContext.setAttribute(attr);
           clayContext.setDisplayElement(displayElement);
           clayContext.setSymbols(displayElement.getSymbols());
          
           isFinal = command.execute(clayContext);
           assertEquals("command finished", true, isFinal);      
           assertEquals("value = null", null, child.getValue());

           //no symbol replacement for a empty string - should return
           //an empty string.  This allows components like the selectItem
           //to create an empty select list pick.
           attr.setValue("")//empty string          
           child = (javax.faces.component.html.HtmlOutputText)
                        facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
           assertNotNull("javax.faces.HtmlOutputText", child);

           clayContext.setFacesContext(facesContext);
           clayContext.setChild(child);
           clayContext.setAttribute(attr);
           clayContext.setDisplayElement(displayElement);
          
           isFinal = command.execute(clayContext);
           assertEquals("command finished", true, isFinal);      
           assertEquals("value = \"\"", "", child.getValue());

           //Case insensitive and reoccurring replacement
           attr.setValue("@TeSt1, @tEst1 never @test2; @test1, @teSt1 till ya @tesT3")//test multiple symbols          
           child = (javax.faces.component.html.HtmlOutputText)
                     facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
           assertNotNull("javax.faces.HtmlOutputText", child);

           displayElement.addSymbol(createSymbol("@test1", "rock"));
View Full Code Here

        javax.faces.component.html.HtmlOutputText child = (javax.faces.component.html.HtmlOutputText)
                           facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
        assertNotNull("javax.faces.HtmlOutputText", child);
       
        //setup some metadata
        AttributeBean attr = new AttributeBean();
        attr.setName("value");
        attr.setBindingType(AttributeBean.BINDING_TYPE_NONE);
        attr.setValue("@[a]@[ab]")//symbolic attribute
                  
        ComponentBean displayElement = new ComponentBean();
        displayElement.setJsfid("inputText");
        displayElement.setComponentType("javax.faces.HtmlOutputText");
        displayElement.setId("testId");
        displayElement.addAttribute(attr);
        displayElement.addSymbol(createSymbol("@[ab]", "43"));
        displayElement.addSymbol(createSymbol("@[a]", "67"));
            
        ClayContext clayContext = new ClayContext();
        clayContext.setFacesContext(facesContext);
        clayContext.setChild(child);
        clayContext.setAttribute(attr);
        clayContext.setDisplayElement(displayElement);
        // normally done in the AssignChildrenCommand
        clayContext.setSymbols(displayElement.getSymbols());
               
        Command command = new PropertyValueCommand();
        boolean isFinal = command.execute(clayContext);
        assertEquals("command finished", true, isFinal);      
        assertEquals("value = 6743", "6743", child.getValue());     

   
        //create a target component
        child = (javax.faces.component.html.HtmlOutputText)
                           facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
        assertNotNull("javax.faces.HtmlOutputText", child);

        attr.setValue("@{a}@{ab}")//symbolic attribute
        displayElement.addSymbol(createSymbol("@{ab}", "43"));
        displayElement.addSymbol(createSymbol("@{a}", "67"));

        clayContext.setChild(child);

        isFinal = command.execute(clayContext);
        assertEquals("command finished", true, isFinal);      
        assertEquals("value = 6743", "6743", child.getValue());     


       
        //create a target component
        child = (javax.faces.component.html.HtmlOutputText)
                           facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
        assertNotNull("javax.faces.HtmlOutputText", child);

        attr.setValue("@(a)@(ab)")//symbolic attribute
        displayElement.addSymbol(createSymbol("@(ab)", "43"));
        displayElement.addSymbol(createSymbol("@(a)", "67"));

        clayContext.setChild(child);
View Full Code Here

        ComponentBean target = (ComponentBean) classz.newInstance();
        target.setJsfid("verbatim");
        target.setComponentType("javax.faces.HtmlOutputText");

        AttributeBean attr = new AttributeBean();
        attr.setBindingType(AttributeBean.BINDING_TYPE_VALUE);
        attr.setName("value");
        attr.setValue(value);
        target.addAttribute(attr);

        attr = new AttributeBean();
        attr.setBindingType(AttributeBean.BINDING_TYPE_NONE);
        attr.setName("escape");
        attr.setValue(Boolean.FALSE.toString());
        target.addAttribute(attr);

        attr = new AttributeBean();
        attr.setBindingType(AttributeBean.BINDING_TYPE_NONE);
        attr.setName("isTransient");
        attr.setValue(Boolean.TRUE.toString());
        target.addAttribute(attr);

        return target;
    }
View Full Code Here

TOP

Related Classes of org.apache.shale.clay.config.beans.AttributeBean

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.