Examples of ComponentBean


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

                || !(component instanceof Clay)) {
            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();
        StringBuffer buff = new StringBuffer(url);

        // look for a classpath prefix.
        int i = buff.indexOf(Globals.CLASSPATH_PREFIX);
        if (i > -1) {
            buff.delete(0, i + Globals.CLASSPATH_PREFIX.length());
        }

        InputStream in = null;

        try {
            // if classpath prefix found, use the classloader
            if (i > -1) {
                // load form the classpath
                ClassLoader classloader = Thread.currentThread()
                        .getContextClassLoader();
                if (classloader == null) {
                    classloader = this.getClass().getClassLoader();
                }

                in = classloader.getResourceAsStream(buff.toString());

            } else {
                // load from the context root
                in = context.getExternalContext().getResourceAsStream(
                        buff.toString());
            }

            if (in != null) {
                int c = 0;
                done: while (true) {
                    c = in.read();
                    if (c > -1) {
                        value.append((char) c);
                    } else {
                        break done;
                    }

                }
            }
        } catch (IOException e) {
            throw new RuntimeException(messages.getMessage("invalid.attribute",
                    new Object[] { "url", "clayImport" }));
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    in = null;
                }
            }

        }

        if (escAttribute != null) {
            if (!escapeXml) {
                replace(value, decodeMap);
            } else {
                replace(value, encodeMap);
            }
        }

        text.setJsfid("outputText");
        text.setComponentType("javax.faces.HtmlOutputText");

        // add a value attribute
        AttributeBean attr = new AttributeBean();
        attr.setName("value");
        attr.setValue(value.toString());
        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);
    }

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

            throw new NullPointerException(messages
                    .getMessage("clay.config.notloaded"));
        }

        // make sure it's parsed and cached
        ComponentBean b = config.getElement(bodyJsfid);
        if (b == null) {
            throw new NullPointerException(messages.getMessage(
                    "clay.jsfid.notfound", new Object[] { bodyJsfid }));
        }

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

            throw new NullPointerException(messages
                    .getMessage("clay.config.notloaded"));
        }

        // find the top-level display element associated with the subtree
        ComponentBean b = config.getElement(getJsfid());
        if (b == null) {
            throw new NullPointerException(messages.getMessage(
                    "clay.jsfid.notfound", new Object[] { getJsfid() }));
        }

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

        //The challenge here is that the symbol replacement happens after the
        //HTML node has been thrown out.  Look to see if the clayJsfid can be
        //found in the forming ComponentBean.
        if (getJsfid() == null) {
            String attrClayJsfid = "null";
            ComponentBean displayElement = (ComponentBean) getAttributes().get(Globals.CLAY_RESERVED_ATTRIBUTE);
            AttributeBean attr = displayElement.getAttribute("clayJsfid");
            if (displayElement != null && (attr != null)) {
                attrClayJsfid = attr.getValue();
            }
            throw new NullPointerException(messages.getMessage("clay.jsfid.null",
                  new Object[] { attrClayJsfid}));
        }

        if (getDisplayElementRoot() == null) {
            if (!getJsfid().equals(Globals.RUNTIME_ELEMENT_ID)) {
                displayElementRoot = getRootElement();
            } else {
                displayElementRoot = new ComponentBean();
                displayElementRoot.setComponentType("javax.faces.HtmlOutputText");
                displayElementRoot.setJsfid(getJsfid());

            }

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

        }
        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) {

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

        if (log.isInfoEnabled()) {
            log.info(messages.getMessage("loading.template",
                    new Object[] { templateName }));
        }

        ComponentBean root = new ComponentBean();
        root.setJsfid(templateName);
        root.setComponentType("javax.faces.HtmlOutputText");

        // generate the document

        StringBuffer buffer = loadTemplate(templateURL);

        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 {
                renderer.encode(node, child, root);
            }

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

        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"));
        }

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

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

        Validator validator = null;
        try {
            AttributeBean attr = displayElement.getAttribute("binding");
            if (attr != null && isValueReference(attr.getValue())) {
                clayContext.setAttribute(attr);
                String expr = replaceMnemonic(clayContext);
                ValueBinding vb = facesContext.getApplication()
                        .createValueBinding(expr);
                validator = (Validator) vb.getValue(facesContext);

            } else {
                validator = facesContext.getApplication().createValidator(
                        displayElement.getComponentType());
            }
        } catch (Exception e) {
            log.error(getMessages().getMessage("create.validator.error",
                    new Object[] { displayElement }), e);
            throw e;

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

        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"));
        }

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

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

            AttributeBean attr = displayElement.getAttribute("binding");
            if (attr != null && isValueReference(attr.getValue())) {
                clayContext.setAttribute(attr);
                String expr = replaceMnemonic(clayContext);
                ValueBinding vb = facesContext.getApplication().createValueBinding(expr);
                converter = (Converter) vb.getValue(facesContext);
            } else {
                // the default converter id comes for the component type
                String converterId = displayElement.getComponentType();
                // check for a converterId attribute override
                attr = displayElement.getAttribute("converterId");
                if (attr != null && attr.getValue() != null
                        && attr.getValue().length() > 0) {
                    clayContext.setAttribute(attr);
                    String tmp = getTagUtils().evalString(replaceMnemonic(clayContext));
                    if (tmp != null && tmp.length() > 0) {

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

        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"));
        }

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

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

        ValueChangeListener listener = null;
        try {

            AttributeBean attr = displayElement.getAttribute("binding");
            if (attr != null && isValueReference(attr.getValue())) {
                clayContext.setAttribute(attr);
                String expr = replaceMnemonic(clayContext);
                ValueBinding vb = facesContext.getApplication().createValueBinding(expr);
                listener = (ValueChangeListener) vb.getValue(facesContext);

            } else {

                ClassLoader loader = Thread.currentThread().getContextClassLoader();
                if (loader == null) {
                    loader = getClass().getClassLoader();
                }

                listener = (ValueChangeListener) loader.loadClass(
                        displayElement.getComponentType()).newInstance();

                loader = null;
            }
        } catch (Exception e) {
            log.error(getMessages().getMessage("create.valueChangeListener"), e);

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

        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.getValueChangeListeners().size() > 0) {
            if (child instanceof EditableValueHolder) {

                Iterator vi = displayElement.getValueChangeListenerIterator();
                while (vi.hasNext()) {
                    ValueChangeListenerBean valueChangeListener = (ValueChangeListenerBean) vi
                            .next();

                    ClayContext subContext = (ClayContext) clayContext.clone();
TOP
Copyright © 2018 www.massapi.com. 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.