Package org.apache.shale.clay.component

Examples of org.apache.shale.clay.component.Clay


        // create a fake clay root display element bean
        ComponentBean displayElementRoot = new ComponentBean();

        // create a mock component for the validator style/signature
        // of method binding
        Clay component = new Clay();
        component.setId("RUNTIME");
        component.setManagedBeanName("rolodex");
        component.setShapeValidator("#{rolodex.createTabs}");

        // make the last tab active
        viewController.setSelectedTab(RolodexDao.TAB_INDEX.length - 1);

        // simulate the the "shapeValidator" event is fired from the
View Full Code Here


          if (!(parentComponent instanceof Clay)) {
              throw new JspException(messages.getMessage("clayparent.notfound"));
          }

          Clay clayParent = (Clay) parentComponent;

          StringBuffer tmp = new StringBuffer(name);
          if (tmp.charAt(0) != '@') {
            tmp.insert(0, '@');
          }
          SymbolBean symbol = new SymbolBean();
          symbol.setName(tmp.toString());
          symbol.setValue(value);
          clayParent.getSymbols().put(symbol.getName(), symbol);

          return super.doStartTag();
    }
View Full Code Here

     * @param component {@link UIComponent} instance of {@link org.apache.shale.clay.component.Clay}
     */
    protected void setProperties(UIComponent component) {
        super.setProperties(component);

        Clay c = (Clay) component;
        FacesContext facesContext = getFacesContext();

        if (getJsfid() != null) {

            c.setJsfid(getJsfid());

        }


        if (getManagedBeanName() != null) {
            c.setManagedBeanName(getManagedBeanName());

            if (isValueReference(getManagedBeanName())) {
                ValueBinding valueBinding = facesContext.getApplication().createValueBinding(getManagedBeanName());
                Object value = valueBinding.getValue(facesContext);
                c.setManagedBeanName((value != null) ? value.toString() : null);

            } else {
                c.setManagedBeanName(getManagedBeanName());
            }

        }


        if (getShapeValidator() != null) {
            c.setShapeValidator(getShapeValidator());
        }

    }
View Full Code Here

            throw new RuntimeException(messages.getMessage("invalid.binding",
                    new Object[] { "clayOut" }));
        }

        ComponentBean text = (ComponentBean) displayElementRoot;
        Clay clay = (Clay) component;
        String value = (String) clay.getAttributes().get("value");
        value = tagUtils.evalString(value);
        if (value == null) {
            throw new IllegalArgumentException(messages.getMessage(
                    "missing.attribute", new Object[] { "value", "clayOut" }));
        }

        boolean escapeXml = false;
        String tmp = (String) clay.getAttributes().get("escapeXml");
        if (tmp != null) {
            escapeXml = tagUtils.evalBoolean(tmp).booleanValue();
        }

        if (!escapeXml) {
View Full Code Here

            throw new RuntimeException(messages.getMessage("invalid.binding",
                    new Object[] { "clayImport" }));
        }

        ComponentBean text = (ComponentBean) displayElementRoot;
        Clay clay = (Clay) component;
        String url = (String) clay.getAttributes().get("url");
        if (url == null) {
            throw new IllegalArgumentException(messages.getMessage(
                    "missing.attribute", new Object[] { "url", "clayImport" }));
        }
        url = tagUtils.evalString(url);

        boolean escapeXml = true;
        String escAttribute = (String) clay.getAttributes().get("escapeXml");
        if (escAttribute != null) {
            escapeXml = tagUtils.evalBoolean(escAttribute).booleanValue();
        }

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

                || !(component instanceof Clay)) {
            throw new RuntimeException(messages.getMessage("invalid.binding",
                    new Object[] { "clayForEach" }));
        }

        Clay clay = (Clay) component;
        String value = (String) clay.getAttributes().get("value");
        if (value == null) {
            throw new IllegalArgumentException(messages.getMessage(
                    "missing.attribute",
                    new Object[] { "value", "clayForEach" }));
        }

        String bodyJsfid = (String) clay.getAttributes().get("bodyJsfid");
        bodyJsfid = tagUtils.evalString(bodyJsfid);
        if (bodyJsfid == null) {
            throw new IllegalArgumentException(messages.getMessage(
                    "missing.attribute", new Object[] { "bodyJsfid",
                            "clayForEach" }));
        }

        String var = (String) clay.getAttributes().get("var");
        var = tagUtils.evalString(var);
        if (var == null) {
            throw new IllegalArgumentException(messages.getMessage(
                    "missing.attribute", new Object[] { "var", "clayForEach" }));
        }
View Full Code Here

       
        //done by the startup context listener
        loadConfigFiles(null, null);
       
       
        Clay clay = (Clay) application.createComponent("org.apache.shale.clay.component.Clay");   
        clay.setId("test");
        clay.setJsfid("/org/apache/shale/clay/config/comment.html");
        clay.setManagedBeanName("test");
               
        //builds a buffer to write the page to
        StringWriter writer = new StringWriter();
        //create a buffered response writer
        ResponseWriter buffResponsewriter = facesContext.getRenderKit()
                        .createResponseWriter(writer, null, response.getCharacterEncoding());
        //push buffered writer to the faces context
        facesContext.setResponseWriter(buffResponsewriter);
        //start a document
        buffResponsewriter.startDocument();
       
        //render HTML
        clay.encodeBegin(facesContext);
        clay.encodeChildren(facesContext);
        clay.encodeEnd(facesContext);
       
        //end the document
        buffResponsewriter.endDocument();
       
        Parser p = new Parser();
View Full Code Here

   
    //Tests the handling of a comment in a nested template.
    public void testNested() throws Exception {
        loadConfigFiles(null, null);
       
        Clay clay = (Clay) application.createComponent("org.apache.shale.clay.component.Clay");   
        clay.setId("test");
        clay.setJsfid("/org/apache/shale/clay/config/layout.html");
        clay.setManagedBeanName("test");
       
        //the clayJsfid in the layout.html is a early EL "#{viewId}"
        request.setAttribute("viewId", "/org/apache/shale/clay/config/comment.html");
       
        //builds a buffer to write the page to
        StringWriter writer = new StringWriter();
        //create a buffered response writer
        ResponseWriter buffResponsewriter = facesContext.getRenderKit()
        .createResponseWriter(writer, null, response.getCharacterEncoding());
        //push buffered writer to the faces context
        facesContext.setResponseWriter(buffResponsewriter);
        //start a document
        buffResponsewriter.startDocument();
       
        clay.encodeBegin(facesContext);
        clay.encodeChildren(facesContext);
        clay.encodeEnd(facesContext);
       
        //end the document
        buffResponsewriter.endDocument();
       
        Parser p = new Parser();
View Full Code Here

        //done by the startup context listener
        loadConfigFiles(null, null);
        response.setCharacterEncoding("UTF-8");
       
       
        Clay clay = (Clay) application.createComponent("org.apache.shale.clay.component.Clay");   
        clay.setId("test");
        clay.setJsfid("/org/apache/shale/clay/config/some-utf-8.html");
        clay.setManagedBeanName("test");
               
        //builds a buffer to write the page to
        StringWriter writer = new StringWriter();
        //create a buffered response writer
        ResponseWriter buffResponsewriter = facesContext.getRenderKit()
                        .createResponseWriter(writer, null, response.getCharacterEncoding());
        //push buffered writer to the faces context
        facesContext.setResponseWriter(buffResponsewriter);
        //start a document
        buffResponsewriter.startDocument();
       
        //render HTML
        clay.encodeBegin(facesContext);
        clay.encodeChildren(facesContext);
        clay.encodeEnd(facesContext);
       
        //end the document
        buffResponsewriter.endDocument();
       
        Parser p = new Parser();
View Full Code Here

TOP

Related Classes of org.apache.shale.clay.component.Clay

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.