Package org.apache.cocoon.woody.formmodel

Examples of org.apache.cocoon.woody.formmodel.Widget


                if (repeaterWidget && !(widget instanceof Repeater)) {
                    throw new SAXException("WoodyTemplateTransformer: the element \"repeater-widget\" can only be used for repeater widgets.");
                }
            } else if (localName.equals(WIDGET_LABEL)) {
                checkContextWidgetAvailable(qName);
                Widget widget = getWidget(attributes);
                widget.generateLabel(contentHandler);
            } else if (localName.equals(REPEATER_WIDGET_LABEL)) {
                checkContextWidgetAvailable(qName);
                Widget widget = getWidget(attributes);
                if (!(widget instanceof Repeater)) {
                    throw new SAXException("WoodyTemplateTransformer: the element \"repeater-widget-label\" can only be used for repeater widgets.");
                }
                String widgetId = attributes.getValue("widget-id");
                if (widgetId == null || widgetId.equals("")) {
                    throw new SAXException("WoodyTemplateTransformer: the element \"repeater-widget-label\" requires a \"widget-id\" attribute.");
                }
                ((Repeater)widget).generateWidgetLabel(widgetId, contentHandler);
            } else if (localName.equals(REPEATER_SIZE)) {
                checkContextWidgetAvailable(qName);
                Widget widget = getWidget(attributes);
                if (!(widget instanceof Repeater))
                    throw new SAXException("WoodyTemplateTransformer: the element \"repeater-size\" can only be used for repeater widgets.");
                contentHandler.startPrefixMapping(Constants.WI_PREFIX, Constants.WI_NS);
                ((Repeater)widget).generateSize(contentHandler);
                contentHandler.endPrefixMapping(Constants.WI_PREFIX);
View Full Code Here


    protected Widget getWidget(Attributes attributes) throws SAXException {
        String widgetId = attributes.getValue("id");
        if (widgetId == null || widgetId.equals("")) {
            throw new SAXException("WoodyTemplateTransformer: missing id attribute on a woody element.");
        }
        Widget widget = contextWidget.getWidget(widgetId);
        if (widget == null) {
            throw new SAXException("WoodyTemplateTransformer: widget with id \"" + widgetId + "\" does not exist in the container " + contextWidget.getFullyQualifiedId());
        }
        return widget;
    }
View Full Code Here

        }
        return widgetId;
    }

    protected Widget getWidget(String widgetId) throws SAXException {
        Widget widget = contextWidget.getWidget(widgetId);
        if (widget == null) {
            if (contextWidget.getFullyQualifiedId() == null) {
                throwSAXException("Widget with id \"" + widgetId + "\" does not exist in the form container.");
            } else {
                throwSAXException("Widget with id \"" + widgetId + "\" does not exist in the container \"" +
View Full Code Here

    public class WidgetLabelHandler extends Handler {
        public Handler process() throws SAXException {
            switch (event) {
            case EVENT_START_ELEMENT:
                widgetId = getWidgetId(input.attrs);
                Widget widget = getWidget(widgetId);
                widget.generateLabel(getContentHandler());
                widget = null;
                return this;
            case EVENT_ELEMENT:
                return nullHandler;
            case EVENT_END_ELEMENT:
View Full Code Here

     * Narrows the scope on the form-model to the member widget-field, and
     * narrows the scope on the object-model to the member xpath-context
     * before continuing the binding over the child-bindings.
     */
    public void doLoad(Widget frmModel, JXPathContext jxpc) throws BindingException {
        Widget widget = frmModel.getWidget(this.widgetId);
        JXPathContext subContext = jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
        if (!(widget instanceof Union))
            throw new RuntimeException("Binding: Expected Union widget, but received class: \"" +
                    widget.getClass().getName() + "\".");
        Union unionWidget = (Union)widget;
        Binding[] subBindings = getChildBindings();
        if (subBindings != null) {
            int size = subBindings.length;
            for (int i = 0; i < size; i++) {
View Full Code Here

  } else if (delegate instanceof MultiValueField) {
            if (id.equals("length")) {
                return true;
            }
        } else if (delegate != null) {
            Widget sub = delegate.getWidget(id);
            if (sub != null) {
                return true;
            }
        }
        return super.has(id, start);
View Full Code Here

            if (id.equals("length")) {
                Object[] values = (Object[])delegate.getValue();
                return new Integer(values.length);
            }
        } else if (delegate != null) {
            Widget sub = delegate.getWidget(id);
            if (sub != null) {
                if (sub instanceof Field ||
                    sub instanceof BooleanField ||
                    sub instanceof AggregateField) {
                    return sub.getValue();
                }
                return wrap(sub);
            }
        }
        return super.get(id, start);
View Full Code Here

                        repeater.addRow();
                    }
                }
            }
        } else if (delegate != null) {
            Widget sub = delegate.getWidget(id);
            if (sub instanceof Field) {
                Field field = (Field)sub;
                value = unwrap(value);
                if (value instanceof Double) {
                    // make woody accept a JS Number
View Full Code Here

    public void loadFormFromModel(Widget frmModel, JXPathContext jctx) {
       
        if (this.loadScript == null) return;
       
        Widget widget = frmModel.getWidget(this.id);
       
        // Move to widget context
        Pointer pointer = jctx.getPointer(this.path);

        // FIXME: remove this ugly hack and get the request from the Avalon context once
View Full Code Here

    }

    public void saveFormToModel(Widget frmModel, JXPathContext jctx) throws BindingException {
        if (this.saveScript == null) return;
       
        Widget widget = frmModel.getWidget(this.id);

        // Move to widget context and create the path if needed
        Pointer pointer = jctx.createPath(this.path);
        JXPathContext widgetCtx = jctx.getRelativeContext(pointer);
        try {
View Full Code Here

TOP

Related Classes of org.apache.cocoon.woody.formmodel.Widget

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.