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

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


     */
    protected ElementBean createCommandLinkMetadata(SelectItem item,
            FacesContext context) {

        // create a command link attribute
        ElementBean link = new ElementBean();
        link.setRenderId(generateId());
        link.setJsfid("commandLink");
        link.setComponentType("javax.faces.HtmlCommandLink");

        // add a value attribute
        AttributeBean attr = new AttributeBean();
        attr.setName("value");
        attr.setValue(item.getLabel());
        link.addAttribute(attr);

        // turn on the the immediate attribute so the validation
        // logic is not invoked when switching tabs
        attr = new AttributeBean();
        attr.setName("immediate");
        attr.setValue("true");
        link.addAttribute(attr);

        // add a action method binding event when the link is clicked
        attr = new AttributeBean();
        attr.setName("action");
        attr.setValue("#{@managed-bean-name.changeTab}");
        link.addAttribute(attr);

        // create a parameter
        ElementBean param = new ElementBean();
        param.setJsfid("param");
        param.setComponentType("javax.faces.Parameter");
        // RenderId is the key to the Map. Increment for each new parameter
        param.setRenderId(generateId());

       
        // add a query param for the selected tab index
        attr = new AttributeBean();
        attr.setName("name");
        attr.setValue("tabIndex");
        param.addAttribute(attr);

        // add a query parameter for the tab index
        attr = new AttributeBean();
        attr.setName("value");
        attr.setValue(((Integer) item.getValue()).toString());
        param.addAttribute(attr);

        // add a parameter to the commandLink
        link.addChild(param);

        return link;
View Full Code Here


     * @return A clay element bean used to construct a faces outputText
     *         component.
     */
    protected ElementBean createVerbatimMetadata(String html, String renderExp,
            FacesContext context) {
        ElementBean text = createVerbatimMetadata(html, context);

        // add a rendered attribute
        AttributeBean attr = new AttributeBean();
        attr.setName("rendered");
        attr.setValue(renderExp);
        attr.setBindingType(AttributeBean.BINDING_TYPE_VALUE);
        text.addAttribute(attr);

        return text;

    }
View Full Code Here

     */
    protected ElementBean createVerbatimMetadata(String html,
            FacesContext context) {

        // create an output Text
        ElementBean text = new ElementBean();
        text.setRenderId(generateId());
        text.setJsfid("f:verbatim");
        text.setComponentType("javax.faces.HtmlOutputText");
            
        // add a value attribute
        AttributeBean attr = new AttributeBean();
        attr.setName("value");
        attr.setValue(html);
        text.addAttribute(attr);

        // add a escape attribute
        attr = new AttributeBean();
        attr.setName("escape");
        attr.setValue(Boolean.FALSE.toString());
        text.addAttribute(attr);
       
        // add a isTransient attribute
        attr = new AttributeBean();
        attr.setName("isTransient");
        attr.setValue(Boolean.TRUE.toString());
        text.addAttribute(attr);

        return text;
    }
View Full Code Here

                // add the subscripted bean to the beans map with the generated
                // key
                beans.put(id.toString(), vi.next());

                // create a naming container to hold the row
                ElementBean namingContainer = new ElementBean();
                namingContainer.setRenderId(i);
                namingContainer.setJsfid("namingContainer");
                namingContainer.setComponentType("javax.faces.NamingContainer");

                // create a new nested bean
                ElementBean target = new ElementBean();
                target.setJsfid(bodyJsfid);
                target.setExtends(bodyJsfid);
                target.setRenderId(i);
                config.assignParent(target);
                config.realizingInheritance(target);

                // prepend the var to the generated key
                id.insert(0, var + ".");
                SymbolBean symbol = new SymbolBean();
                symbol.setName(Globals.MANAGED_BEAN_MNEMONIC);
                symbol.setValue(id.toString());
                target.addSymbol(symbol);

                namingContainer.addChild(target);
                ((ComponentBean) displayElementRoot).addChild(namingContainer);
            }
View Full Code Here

        // verbatim ending tags must be another node since they are flat and
        // don't have children
        if (node.isStart() && !node.isEnd() && node.isWellFormed()) {

            ElementBean endTarget = createElement(node);
            root.addChild(endTarget);

            StringBuffer tmp = new StringBuffer();
            tmp.append("</").append(node.getName()).append(">");

            AttributeBean attr = new AttributeBean();
            attr.setBindingType(AttributeBean.BINDING_TYPE_NONE);
            attr.setName("value");
            attr.setValue(tmp.toString());
            endTarget.addAttribute(attr);

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

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

        }
    }
View Full Code Here

        List roots = new Parser().parse(buffer);
        Iterator ri = roots.iterator();
        while (ri.hasNext()) {
            Node node = (Node) ri.next();
            Builder renderer = getBuilder(node);
            ElementBean child = renderer.createElement(node);

            root.addChild(child);
            if (renderer.isChildrenAllowed()) {
                renderer.encode(node, child, child);
            } else {
View Full Code Here

            Iterator ci = node.getChildren().iterator();
            while (ci.hasNext()) {
                Node child = (Node) ci.next();
                Builder childRenderer = getBuilder(child);

                ElementBean targetChild = childRenderer.createElement(child);
                root.addChild(targetChild);
                //if the child component allows children, pass it to the render as
                // the root, otherwise, add the child to the current root
                if (childRenderer.isChildrenAllowed()) {
                    childRenderer.encode(child, targetChild, targetChild);
View Full Code Here

     * @param node markup
     * @return target config bean from the markup node
     */
    public ElementBean createElement(Node node) {

        ElementBean target = new ElementBean();
        target.setJsfid(getJsfid(node));
        if (!node.isComment() && node.isStart()) {
            String jsfid = (String) node.getAttributes().get("jsfid");
            if (jsfid != null) {
               target.setJsfid(jsfid);
            }
        }
        target.setComponentType(getComponentType(node));
        target.setRenderId(getRenderId());

        return target;
    }
View Full Code Here

        assertNotNull(bean);
       
        assertEquals(bean.getChildren().size(), 2);
        Iterator ei = bean.getChildrenIterator();
        while (ei.hasNext()) {
            ElementBean ebean = (ElementBean) ei.next();
            if (ebean.getRenderId() == 1) {
                //look for inherited symbol
                symbol = (SymbolBean) ebean.getSymbols().get("@mystyle");
                assertNotNull(symbol);
                assertEquals("@mystyle == color:blue", "color:blue", symbol.getValue());               
            } else if (ebean.getRenderId() == 2) {
                //look for an overridden symbol
                symbol = (SymbolBean) ebean.getSymbols().get("@mystyle");
                assertNotNull(symbol);
                assertEquals("@mystyle == color:red", "color:red", symbol.getValue());
               
            }
        }
View Full Code Here

     *
     * @param node markup
     * @return config bean
     */
    public ElementBean createElement(Node node) {
        ElementBean target = super.createElement(node);
        String renderId = (String) node.getAttributes().get("renderId");
        if (renderId != null) {
           Integer id = null;
           try {
            id = Integer.valueOf(renderId);
           } catch (NumberFormatException e) {
               log.error(e);
               throw new RuntimeException(
                       messages.getMessage("parser.unresolved",
                       new Object[] {node.getToken(), node.getToken().getRawText()}));
           }
           if (id != null) {
              target.setRenderId(id.intValue());
           }
        }

        return target;
    }
View Full Code Here

TOP

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

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.