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

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


    public void testLoadXHTMLJsfHtmlCore4() {

        //loads the default and the custom address config file
        loadConfigFile("/org/apache/shale/clay/config/address-config.xml");

        ComponentBean bean = htmlTemplateConfigBean.getElement("/org/apache/shale/clay/config/address4.html");
        assertNotNull(bean);

        Iterator ci = bean.getChildrenIterator();
        while (ci.hasNext()) {
           ElementBean child = (ElementBean) ci.next();
           //look for a component that we have setup to test
           checkComponent(child, CUSTOM_HTML_COMPONENTS, true);   
        }
View Full Code Here


    public void testLoadXHTMLJsfHtmlCore5() {

        //loads the default and the custom address config file
        loadConfigFile("/org/apache/shale/clay/config/address-config.xml");

        ComponentBean bean = htmlTemplateConfigBean.getElement("/org/apache/shale/clay/config/address5.html");
        assertNotNull(bean);

        Iterator ci = bean.getChildrenIterator();
        while (ci.hasNext()) {
           ElementBean child = (ElementBean) ci.next();
           //look for a component that we have setup to test
           checkComponent(child, CUSTOM_HTML_COMPONENTS, false);   
        }
View Full Code Here

    public void testLoadXMLFileOnDemand() {
       
        //loads the default and the custom address config file
        loadConfigFile("/org/apache/shale/clay/config/address-config.xml");
       
        ComponentBean bean = xmlTemplateConfigBean.getElement("/org/apache/shale/clay/config/address.xml");
        assertNotNull(bean);
       
        Iterator ci = bean.getChildrenIterator();
        while (ci.hasNext()) {
            ElementBean child = (ElementBean) ci.next();
           
            AttributeBean attr = null;
            if (child.getId().equals("htmlBegin")) {
View Full Code Here

                        "/org/apache/shale/clay/config/address-fullxml.xml");
       
        //loaded on startup, this call will just retrieve a loaded definitions
        //the jsfid doesn't match the name of the config file, a requirement
        //for on-demand full xml views
        ComponentBean bean = xmlTemplateConfigBean.getElement("/address2.xml");
        assertNotNull(bean);
       
        Iterator ci = bean.getChildrenIterator();
        while (ci.hasNext()) {
            ElementBean child = (ElementBean) ci.next();
           
            AttributeBean attr = null;
            if (child.getId().equals("htmlBegin")) {
View Full Code Here

           assertEquals("check.children.cnt for " + sarg, childrenCnt, bean.getChildren().size());   
        }
       
        Iterator ci = bean.getChildrenIterator();
        while (ci.hasNext()) {
           ComponentBean child = (ComponentBean) ci.next();
           checkComponent(child, knownGoodStates, useJsfid);
        }

        if (validatorCnt > -1) {
            assertEquals("check.validator.cnt for " + sarg, validatorCnt, bean.getValidators().size());   
        }
       
        ci = bean.getValidatorIterator();
        while (ci.hasNext()) {
           ComponentBean child = (ComponentBean) ci.next();
           checkComponent(child, knownGoodStates, useJsfid);
        }

        if (actionListenerCnt > -1) {
            assertEquals("check.actionListener.cnt for " + sarg, actionListenerCnt, bean.getActionListeners().size());   
        }
       
        ci = bean.getActionListenerIterator();
        while (ci.hasNext()) {
           ComponentBean child = (ComponentBean) ci.next();
           checkComponent(child, knownGoodStates, useJsfid);
        }

        if (valueChangeListenerCnt > -1) {
            assertEquals("check.valueChangeListener.cnt for " + sarg, valueChangeListenerCnt, bean.getValueChangeListeners().size());   
        }
              
        ci = bean.getValueChangeListenerIterator();
        while (ci.hasNext()) {
           ComponentBean child = (ComponentBean) ci.next();
           checkComponent(child, knownGoodStates, useJsfid);
        }

    }
View Full Code Here

       
        // loads the default and the custom address config file
        loadConfigFile("/org/apache/shale/clay/config/address-config.xml");
       
        try {
            ComponentBean bean = htmlTemplateConfigBean.getElement("org/apache/shale/clay/config/duplicate1.html");
            assertTrue("Duplicate component check", false);
        } catch (RuntimeException e) {
            assertTrue(
                    "Duplicate component check",
                    e.getMessage().startsWith("A duplicate component id (street1) was found within the same naming container"));
        }
       
       
        ComponentBean bean = htmlTemplateConfigBean.getElement("org/apache/shale/clay/config/duplicate2.html");
        assertNotNull("Duplicate component check", bean);
       
       
    }
View Full Code Here

        if (child == null) {
            throw new NullPointerException(getMessages()
                    .getMessage("clay.null.childComponent"));
        }

        ComponentBean displayElement = clayContext.getDisplayElement();
        if (displayElement == null) {
            throw new NullPointerException(getMessages()
                    .getMessage("clay.null.componentBean"));
        }

        if (displayElement.getActionListeners().size() > 0) {
            if (child instanceof ActionSource) {

                Iterator vi = displayElement.getActionListenerIterator();
                while (vi.hasNext()) {
                    ActionListenerBean actionListener = (ActionListenerBean) vi
                            .next();

                    ClayContext subContext = (ClayContext) clayContext.clone();
View Full Code Here

        if (clayContext == null) {
            throw new NullPointerException(getMessages()
                    .getMessage("clay.null.clayContext"));
        }

        ComponentBean displayElement = clayContext.getDisplayElement();
        if (displayElement == null) {
            throw new NullPointerException(getMessages()
                    .getMessage("clay.null.componentBean"));
        }

        if (!displayElement.getComponentType().equals("javax.faces.ViewRoot")) {
           return false;
        }

        FacesContext facesContext = clayContext.getFacesContext();
        if (facesContext == null) {
            throw new NullPointerException(getMessages()
                    .getMessage("clay.null.facesContext"));
        }

        // create a new scoped symbol table
        Map symbolTable = new Attributes();
        // inherit the parents symbols
        symbolTable.putAll(clayContext.getSymbols());
        // override config (XML, HTML) symbols
        symbolTable.putAll(displayElement.getSymbols());
        // push to context
        clayContext.setSymbols(symbolTable);

        // evaluate nested symbols; symbols having symbols as values
        realizeSymbols(clayContext);

        AttributeBean attr = null;
        attr = displayElement.getAttribute("renderKitId");
        if (attr != null && attr.getValue() != null) {
            clayContext.setAttribute(attr);
            String expr = replaceMnemonic(clayContext);
            if (expr != null) {
                if (isValueReference(expr)) {
                    getTagUtils().setValueBinding(facesContext.getViewRoot(), "renderKitId", expr);
                } else {
                    facesContext.getViewRoot().setRenderKitId(expr);
                }
            }
            clayContext.setAttribute(null);
        }
        attr = displayElement.getAttribute("locale");
        if (attr != null && attr.getValue() != null) {
            clayContext.setAttribute(attr);
            String expr = replaceMnemonic(clayContext);
            if (expr != null) {
                if (isValueReference(expr)) {
View Full Code Here

        if (clayContext == null) {
            throw new NullPointerException(getMessages()
                    .getMessage("clay.null.clayContext"));
        }

        ComponentBean displayElement = clayContext.getDisplayElement();
        if (displayElement == null) {
            throw new NullPointerException(getMessages()
                    .getMessage("clay.null.componentBean"));
        }

        UIComponent parent = clayContext.getParent();
        if (parent == null) {
            throw new NullPointerException(getMessages()
                    .getMessage("clay.null.parentBean"));
        }

        FacesContext facesContext = clayContext.getFacesContext();
        if (facesContext == null) {
            throw new NullPointerException(getMessages()
                    .getMessage("clay.null.facesContext"));
        }

        // create a new scoped symbol table
        Map symbolTable = new Attributes();
        // inherit the parents symbols
        symbolTable.putAll(clayContext.getSymbols());
        // override config (XML, HTML) symbols
        symbolTable.putAll(displayElement.getSymbols());
        // push to context
        clayContext.setSymbols(symbolTable);

        // evaluate nested symbols; symbols having symbols as values
        realizeSymbols(clayContext);

        UIComponent child = null;
        Long jspId = new Long(displayElement.getJspId());
        clayContext.getJspIds().add(jspId);

        String facetName = displayElement.getFacetName();
        if (facetName != null) {
            facetName = replaceMnemonic(clayContext, facetName);
        }
        if (facetName != null) {
            child = parent.getFacet(displayElement.getFacetName());
        }
        if (child == null) {
           child = this.findComponentByJspId(parent, jspId);
        }
        // always burn an id; this is to support the early versions of myfaces & RI 1.1
        // the UIViewRoot didn't persist the sequence that is used by the call to createUniqueId
        String id = facesContext.getViewRoot().createUniqueId();
        if (child == null) {
            if (displayElement.getId() != null) {
                id = replaceMnemonic(clayContext, displayElement.getId());
            }
        } else {
            id = child.getId();
        }

        //Check to see if the replacement failed.  This can happen if the
        //symbol is missing.  The id will still containing the symbol delimiter
        //character.  The other scenario is if the value of the symbol is null.

        if (id == null || id.indexOf('@') > -1) {

           if (id == null) {
              id = displayElement.getId();
           }

           throw new RuntimeException(getMessages().getMessage("create.component.invalid.id",
                   new Object[] {id, symbolTable}));
        }

        if (child == null) {
            try {
                AttributeBean attr = displayElement.getAttribute("binding");
                if (attr != null
                    && attr.getValue() != null) {

                   clayContext.setAttribute(attr);
                   String expr = replaceMnemonic(clayContext);
                   ValueBinding vb = facesContext.getApplication().createValueBinding(expr);
                   child = facesContext.getApplication().createComponent(vb, facesContext,
                                                                    displayElement.getComponentType());
                   child.setValueBinding("binding", vb);

                } else {

                   child = facesContext.getApplication().createComponent(
                        displayElement.getComponentType());
                }

            } catch (Exception e) {
                log.error(getMessages().getMessage("create.component.error",
                        new Object[] { displayElement }), e);
                        throw e;
            }

            child.setId(id);
            child.getAttributes().put(Globals.CLAY_JSPID_ATTRIBUTE, jspId);
            if (facetName != null) {
                parent.getFacets().put(facetName, child);

                if (log.isDebugEnabled()) {
                    log.debug(getMessages().getMessage("create.facet.component",
                        new Object[] { id, displayElement.getJsfid()}));
                }

            } else {
                parent.getChildren().add(clayContext.getChildIndex(), child);

                if (log.isDebugEnabled()) {
                    log.debug(getMessages().getMessage("create.component",
                        new Object[] { id, displayElement.getJsfid(), new Integer(clayContext.getChildIndex()) }));
                }

            }

            if (child instanceof Clay) {
                //save the display element used to create the component for exception
                //reporting when the jsfid is null.  This should only happen when using
                //symbol replacement of a nested clay component with HTML views
                child.getAttributes().put(Globals.CLAY_RESERVED_ATTRIBUTE, displayElement);
            }

            // continue with the addComponent chain
            isFinal = false;
        } else {
            if (log.isDebugEnabled()) {
                log.debug(getMessages().getMessage("create.component.exists",
                    new Object[] { id, displayElement.getJsfid(), new Integer(clayContext.getChildIndex()) }));
            }
        }

        // if target is a Clay component it might contain symbols
        if (child instanceof Clay) {
View Full Code Here

        }
        AttributeBean attributeBean = clayContext.getAttribute();
        if (attributeBean == null) {
            throw new NullPointerException(getMessages().getMessage("clay.null.attributeBean"));
        }
        ComponentBean displayElement = clayContext.getDisplayElement();
        if (displayElement == null) {
            throw new NullPointerException(getMessages().getMessage("clay.null.componentBean"));
        }
        FacesContext facesContext = clayContext.getFacesContext();
        if (facesContext == null) {
View Full Code Here

TOP

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

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.