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

        this.convertor = convertor;
        this.convertorLocale = convertorLocale;
    }

    public void doLoad(Widget frmModel, JXPathContext jctx) throws BindingException {
        Widget widget = frmModel.getWidget(this.multiValueId);
        if (widget == null) {
            throw new BindingException("The widget with the ID [" + this.multiValueId
                    + "] referenced in the binding does not exist in the form definition.");
        }

        // Move to multi value context
        Pointer ptr = jctx.getPointer(this.multiValuePath);
        if (ptr.getNode() != null) {
            // There are some nodes to load from

            JXPathContext multiValueContext = jctx.getRelativeContext(ptr);
            // build a jxpath iterator for pointers
            Iterator rowPointers = multiValueContext.iterate(this.rowPath);

            LinkedList list = new LinkedList();

            while (rowPointers.hasNext()) {
                Object value = rowPointers.next();

                if (value != null && convertor != null) {
                    if (value instanceof String) {
                        value = convertor.convertFromString((String)value, convertorLocale, null);
                    } else {
                        getLogger().warn("Convertor ignored on backend-value which isn't of type String.");
                    }
                }

                list.add(value);
            }

            widget.setValue(list.toArray());
        }

        if (getLogger().isDebugEnabled())
            getLogger().debug("done loading values " + toString());
    }
View Full Code Here

        if (getLogger().isDebugEnabled())
            getLogger().debug("done loading values " + toString());
    }

    public void doSave(Widget frmModel, JXPathContext jctx) throws BindingException {
        Widget widget = frmModel.getWidget(this.multiValueId);
        Object[] values = (Object[])widget.getValue();

        JXPathContext multiValueContext = jctx.getRelativeContext(jctx.createPath(this.multiValuePath));
        // Delete all that is already present
        multiValueContext.removeAll(this.rowPath);
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 ||
                    sub instanceof Output) {
                    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

    protected 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

        this.saveScript = saveScript;
    }

    public void doLoad(Widget frmModel, JXPathContext jctx) {
        if (this.loadScript != null) {
            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
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.