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

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


                    .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) {
                        converterId = tmp;
                    }
View Full Code Here


     */
    protected void encodeBegin(Node node, ElementBean target, ComponentBean root) {
        StringBuffer value = new StringBuffer();
        captureComment(node, value);

        AttributeBean attr = new AttributeBean();
        attr.setBindingType(AttributeBean.BINDING_TYPE_NONE);
        attr.setName("value");
        attr.setValue(value.toString());
        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);

    }
View Full Code Here

        }

        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);
View Full Code Here

        ClayContext clayContext = (ClayContext) context;
        if (clayContext == null) {
            throw new NullPointerException(getMessages().getMessage("clay.null.clayContext"));
        }
        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) {
            throw new NullPointerException(getMessages().getMessage("clay.null.facesContext"));
        }
        if (attributeBean.getName().equals("validator") && attributeBean.getValue() != null) {
            isFinal = true;

            UIComponent child = (UIComponent) clayContext.getChild();
            if (child == null) {
                throw new NullPointerException("child");
View Full Code Here

        ClayContext clayContext = (ClayContext) context;
        if (clayContext == null) {
            throw new NullPointerException(getMessages().getMessage("clay.null.clayContext"));
        }
        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.childComponent"));
        }
        FacesContext facesContext = clayContext.getFacesContext();
        if (facesContext == null) {
            throw new NullPointerException(getMessages().getMessage("clay.null.facesContext"));
        }
        if (attributeBean.getName().equals("valueChangeListener") && attributeBean.getValue() != null) {
            isFinal = true;

            UIComponent child = (UIComponent) clayContext.getChild();
            if (child == null) {
                throw new NullPointerException("child");
View Full Code Here

     * @param value attribute property value override
     * @param target owner of the attribute
     * @return cloned original with the value overridden
     */
    protected AttributeBean createAttribute(AttributeBean original, String value, ComponentBean target) {
        AttributeBean attr = new AttributeBean();
        attr.setName(original.getName());
        attr.setValue(value);
        attr.setBindingType(original.getBindingType());
        target.addAttribute(attr);
        return attr;
    }
View Full Code Here

                || e.getKey().equals("facetname")) {

                continue next;
            }

            AttributeBean original = null;
            Token valueToken = (Token) e.getValue();
            if (valueToken != null) {
                original = target.getAttribute((String) e.getKey());
                if (original != null) {
                    createAttribute(original, valueToken.getRawText(), target);
View Full Code Here

        ClayContext clayContext = (ClayContext) context;
        if (clayContext == null) {
            throw new NullPointerException(getMessages().getMessage("clay.null.clayContext"));
        }
        AttributeBean attributeBean = clayContext.getAttribute();
        if (attributeBean == null) {
            throw new NullPointerException(getMessages().getMessage("clay.null.attributeBean"));
        }
        Object child = clayContext.getChild();
        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"));
        }
        FacesContext facesContext = clayContext.getFacesContext();
        if (facesContext == null) {
            throw new NullPointerException(getMessages().getMessage("clay.null.facesContext"));
        }

        // don't try to set the binding attribute of anything but a component
        if (attributeBean.getName().equals("binding")
                && !(child instanceof UIComponent)) {
            return isFinal;

        }
        // skip trying to set the converterId on a converter
        if (attributeBean.getName().equals("converterId")
                && child instanceof Converter) {
            return isFinal;
        }
        // replace all symbols returning the target attribute value
        String expr = replaceMnemonic(clayContext);

        //exit if null or empty string
        if (expr == null) {
           return isFinal;
        }


        String bindingType = attributeBean.getBindingType();
        if (bindingType == null) {
            bindingType = AttributeBean.BINDING_TYPE_NONE;
        }

        //contains expression language
        boolean isEL = isValueReference(expr);
        //use value binding
        boolean isVB = ((bindingType.equals(AttributeBean.BINDING_TYPE_VALUE))
                        && (child instanceof UIComponent));
        //use early binding
        boolean isEarly = bindingType.equals(AttributeBean.BINDING_TYPE_EARLY);

        if (isEL && isVB) {
           getTagUtils().setValueBinding((UIComponent) child, attributeBean.getName(), expr);
        } else if (isEL && isEarly) {
            ValueBinding vb = facesContext.getApplication().createValueBinding(expr);
            Object value = vb.getValue(facesContext);
            try {
                setProperty(facesContext, child, attributeBean.getName(), value);
            } catch (Exception e) {
                 if (child instanceof UIComponent) {
                   ((UIComponent) child).getAttributes().put(attributeBean.getName(), expr);
                 } else {
                    throw e;
                 }
             }
        } else  {
            try {
               setProperty(facesContext, child, attributeBean.getName(), expr);
            } catch (Exception e) {
                if (child instanceof UIComponent) {
                  ((UIComponent) child).getAttributes().put(attributeBean.getName(), expr);
                } else {
                   if (child.getClass().getName().equals("org.apache.shale.validator.CommonsValidator")) {
                      Map vars = (Map) propertyHelper.getValue(child, "vars");
                      //vars collection is like the components attributes
                      //native support for shale components
                      vars.put(attributeBean.getName(), expr);
                   } else {
                      throw e;
                   }
                }
            }
View Full Code Here

     * @param root parent config bean
     */
    protected void encodeBegin(Node node, ElementBean target, ComponentBean root) {
        super.encodeBegin(node, target, root);
        if (getComponentType(node).equals(target.getComponentType())) {
            AttributeBean attr = target.getAttribute("value");
            SymbolBean symbol = target.getSymbol("href");
            if ((symbol != null && attr != null)
                    && (attr.getValue() == null || attr.getValue().length() == 0)) {
                createAttribute(attr, "@href", target);
            }
        }
    }
View Full Code Here

        }

        if (target.getAttributes().containsKey("itemValue")
            && node.getAttributes().containsKey("value")) {
            String value = (String) node.getAttributes().get("value");
            AttributeBean attr = target.getAttribute("itemValue");
            createAttribute(attr, value, target);
        }
        if (target.getAttributes().containsKey("itemLabel")
            && node.getChildren().size() == 1) {

            Node child = (Node) node.getChildren().get(0);
            String value = child.getToken().getRawText();
            AttributeBean attr = target.getAttribute("itemLabel");
            createAttribute(attr, value, 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.