Package org.apache.cocoon.forms

Examples of org.apache.cocoon.forms.FormsException


            // FormDefinition is the *only* kind of widget that has an optional id
            widgetDefinition.setId(DomHelper.getAttribute(widgetElement, "id", ""));
        } else {
            String id = DomHelper.getAttribute(widgetElement, "id");
            if (id.indexOf('/') != -1 || id.indexOf('.') != -1) {
                throw new FormsException("A widget name cannot contain '.' or '/' as this conflicts with widget paths.",
                                         DomHelper.getLocationObject(widgetElement));
            }
            // NewDefinitions are allowed to have a : in their id because they can look up
            // class widgets from the library directly
            if (id.indexOf(':') != -1 && !(widgetDefinition instanceof NewDefinition)) {
                throw new FormsException("A widget name cannot contain ':' as this conflicts with library prefixes",
                                         DomHelper.getLocationObject(widgetElement));
            }
            widgetDefinition.setId(id);
        }

        // state
        String stateValue = DomHelper.getAttribute(widgetElement, "state", null);
        if (stateValue != null) {
            WidgetState state = WidgetState.stateForName(stateValue);
            if (state == null) {
                throw new FormsException("Unknown value '" + stateValue +"' for state attribute.",
                                         DomHelper.getLocationObject(widgetElement));
            }
            widgetDefinition.setState(state);
        }

View Full Code Here


        String widgetName = widgetElement.getLocalName();
        WidgetDefinitionBuilder builder;
        try {
            builder = (WidgetDefinitionBuilder) widgetDefinitionBuilderSelector.select(widgetName);
        } catch (ServiceException e) {
            throw new FormsException("Unknown kind of widget '" + widgetName + "'.",
                                     e, DomHelper.getLocationObject(widgetElement));
        }

        WidgetDefinition def = builder.buildWidgetDefinition(widgetElement, context);
View Full Code Here

                    Element listenerElement = (Element)list.item(i);
                    WidgetListenerBuilder builder;
                    try {
                        builder = (WidgetListenerBuilder) widgetListenerBuilderSelector.select(listenerElement.getLocalName());
                    } catch (ServiceException e) {
                        throw new FormsException("Unknown kind of eventlistener '" + listenerElement.getLocalName() + "'.", e,
                                                 DomHelper.getLocationObject(listenerElement));
                    }
                    WidgetListener listener = builder.buildListener(listenerElement, listenerClass);
                    widgetListenerBuilderSelector.release(builder);
                    if (result == null) {
View Full Code Here

                    String name = element.getLocalName();
                    WidgetValidatorBuilder builder;
                    try {
                        builder = (WidgetValidatorBuilder)this.widgetValidatorBuilderSelector.select(name);
                    } catch(ServiceException e) {
                        throw new FormsException("Unknown kind of validator '" + name + "'.",
                                                 e, DomHelper.getLocationObject(element));
                    }

                    widgetDefinition.addValidator(builder.build(element, widgetDefinition));
                    widgetValidatorBuilderSelector.release(builder);
View Full Code Here

     * Imports a new library
     */
    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
    throws Exception {
        if (context.getLocalLibrary() == null) {
            throw new FormsException("Import statement seen and context is empty.",
                                     DomHelper.getLocationObject(widgetElement));
        }

        Library lib = context.getLocalLibrary();
        String prefix = DomHelper.getAttribute(widgetElement, PREFIX_ATTRIBUTE);
        String uri = DomHelper.getAttribute(widgetElement, URI_ATTRIBUTE);

        if (!lib.includeAs(prefix, uri)) {
            throw new FormsException("Import statement did not succeed (probably used ':' in the prefix?).",
                                     DomHelper.getLocationObject(widgetElement));
        }

        return null;
    }
View Full Code Here

        }

        // parse "@whitespace"
        Whitespace whitespace = Whitespace.getEnum(DomHelper.getAttribute(widgetElement, "whitespace", "trim"));
        if (whitespace == null) {
            throw new FormsException("Unknown value for 'whitespace' attribute; valid values are 'trim', 'trim-start', 'trim-end', and 'preserve'.",
                                     DomHelper.getLocationObject(widgetElement));
        }
        definition.setWhitespaceTrim(whitespace);

        SelectionList list = buildSelectionList(widgetElement, definition, "suggestion-list");
View Full Code Here

    throws Exception {
        String id = DomHelper.getAttribute(element, "id");

        WidgetDefinition definition = context.getLocalLibrary().getDefinition(id);
        if (definition == null) {
            throw new FormsException("Widget '" + id + "' not found.",
                                     DomHelper.getLocationObject(element));
        }

        return definition;
    }
View Full Code Here

        } else if ("multiple".equals(selection)) {
            definition.setSelectionModel(Tree.MULTIPLE_SELECTION);
        } else if ("single".equals(selection)) {
            definition.setSelectionModel(Tree.SINGLE_SELECTION);
        } else {
            throw new FormsException("Invalid value selection value '" + selection + "'.",
                                     DomHelper.getLocationObject(widgetElement));
        }

        // Get the model optional element
        Element modelElt = DomHelper.getChildElement(widgetElement, FormsConstants.DEFINITION_NS, "tree-model", false);
View Full Code Here

*/
public class ButtonDefinitionBuilder extends AbstractWidgetDefinitionBuilder {

    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
    throws Exception {
        throw new FormsException("The button widget has been renamed to action. Please update your form definition files.",
                                 DomHelper.getLocationObject(widgetElement));
    }
View Full Code Here

            // FormDefinition is the *only* kind of widget that has an optional id
            widgetDefinition.setId(DomHelper.getAttribute(widgetElement, "id", ""));
        } else {
            String id = DomHelper.getAttribute(widgetElement, "id");
            if (id.indexOf('/') != -1 || id.indexOf('.') != -1) {
                throw new FormsException("A widget name cannot contain '.' or '/' as this conflicts with widget paths.",
                                         DomHelper.getLocationObject(widgetElement));
            }
            // NewDefinitions are allowed to have a : in their id because they can look up
            // class widgets from the library directly
            if (id.indexOf(':') != -1 && !(widgetDefinition instanceof NewDefinition)) {
                throw new FormsException("A widget name cannot contain ':' as this conflicts with library prefixes",
                                         DomHelper.getLocationObject(widgetElement));
            }
            widgetDefinition.setId(id);
        }

        // state
        String stateValue = DomHelper.getAttribute(widgetElement, "state", null);
        if (stateValue != null) {
            WidgetState state = WidgetState.stateForName(stateValue);
            if (state == null) {
                throw new FormsException("Unknown value '" + stateValue +"' for state attribute.",
                                         DomHelper.getLocationObject(widgetElement));
            }
            widgetDefinition.setState(state);
        }

View Full Code Here

TOP

Related Classes of org.apache.cocoon.forms.FormsException

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.