Package org.apache.cocoon.forms.datatype

Examples of org.apache.cocoon.forms.datatype.Datatype


        }
        if (delegate instanceof DataWidget) {
            value = unwrap(value);
            if (value != null) {
                // Coerce values
                Datatype datatype = ((DataWidget)delegate).getDatatype();
                Class typeClass = datatype.getTypeClass();
                if (typeClass == String.class) {
                    value = Context.toString(value);
                } else if (typeClass == boolean.class ||
                           typeClass == Boolean.class) {
                    value = Context.toBoolean(value) ? Boolean.TRUE : Boolean.FALSE;
View Full Code Here


        }
        if (delegate instanceof DataWidget) {
            value = unwrap(value);
            if (value != null) {
                // Coerce values
                Datatype datatype = ((DataWidget)delegate).getDatatype();
                Class typeClass = datatype.getTypeClass();
                if (typeClass == String.class) {
                    value = Context.toString(value);
                } else if (typeClass == boolean.class ||
                           typeClass == Boolean.class) {
                    value = Context.toBoolean(value) ? Boolean.TRUE : Boolean.FALSE;
View Full Code Here

        }

        //---- parse "datatype"
        Element datatypeElement = DomHelper.getChildElement(widgetElement, FormsConstants.DEFINITION_NS, "datatype");
        if (datatypeElement != null) {
            Datatype datatype = datatypeManager.createDatatype(datatypeElement, isArrayType);

            // ---- parse "initial-value"
            Object initialValue = null;
            Element initialValueElement = DomHelper.getChildElement(widgetElement, FormsConstants.DEFINITION_NS, "initial-value", false);
            if (initialValueElement != null) {
                String localeValue = DomHelper.getAttribute(initialValueElement, "locale", null);
                Locale locale = localeValue == null ? Locale.getDefault() : I18nUtils.parseLocale(localeValue);
                String value = DomHelper.getElementText(initialValueElement);
                ConversionResult result = datatype.convertFromString(value, locale);
                if (!result.isSuccessful()) {
                    throw new FormsException("Cannot parse initial value '" + value + "'.",
                                             DomHelper.getLocationObject(initialValueElement));
                }
                initialValue = result.getResult();
View Full Code Here

TOP

Related Classes of org.apache.cocoon.forms.datatype.Datatype

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.