Package org.apache.cocoon.woody.formmodel

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


     * Actively performs the binding from the ObjectModel wrapped in a jxpath
     * context to the Woody-form-widget specified in this object.
     */
    public void loadFormFromModel(Widget frmModel, JXPathContext jxpc) {
        try {
            Widget widget = frmModel.getWidget(this.fieldId);
            Object value = jxpc.getValue(this.xpath);

            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.");  
                }               
            }

            widget.setValue(value);

            if (getLogger().isDebugEnabled())
                getLogger().debug("done loading " + toString() + " -- value= " + value);
        } catch (Exception e) {
            getLogger().warn("JXPath failed to find value for " + this.xpath, e);
View Full Code Here


     * wrapped in a jxpath context
     */
    public void saveFormToModel(Widget frmModel, JXPathContext jxpc) throws BindingException {
        if (!this.readonly) {
            try {
                Widget widget = frmModel.getWidget(this.fieldId);
                Object value = widget.getValue();
                if (value != null && convertor != null) {
                    value = convertor.convertToString(value, convertorLocale, null);
                }

                Object oldValue = jxpc.getValue(this.xpath);
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("value= " + value + "-- oldvalue=" + oldValue);
                }

                boolean update = false;

                if ((value == null && oldValue != null) || value != null && !value.equals(oldValue)) {
                    // first update the value itself
                    jxpc.createPathAndSetValue(this.xpath, value);

                    // now perform any other bindings that need to be performed when the value is updated
                    JXPathContext subContext = null;
                    try {
                        subContext = jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
                    } catch (JXPathException e) {
                        // if the value has been set to null and the underlying model is a bean, then
                        // JXPath will not be able to create a relative context
                        if (getLogger().isDebugEnabled()) {
                            getLogger().debug("(Ignorable) problem binding field " + widget.getFullyQualifiedId(), e);
                        }
                    }
                    if (subContext != null) {
                        this.updateBinding.saveFormToModel(frmModel, subContext);
                    }
View Full Code Here

        // iterate rows...       
        int formRowCount = repeater.getSize();
        for (int i = 0; i < formRowCount; i++) {
            Repeater.RepeaterRow thisRow = repeater.getRow(i);

            Widget rowIdWidget = thisRow.getWidget(this.uniqueRowId);
            Object rowIdValue = rowIdWidget.getValue();

            if (rowIdValue != null) {
                //if rowIdValue != null --> iterate nodes to find match
                Iterator rowPointers =
                    repeaterContext.iteratePointers(this.rowPath);
View Full Code Here

                throw new SAXException("WoodyTemplateTransformer: the element \"repeater-widget\" can only be used for repeater widgets.");
        } else if (inWidgetElement) {
            xmlCompiler.startElement(namespaceURI, localName, qName, attributes);
        } else if (namespaceURI.equals(Constants.WT_NS)) {
            if (localName.equals("widget-label")) {
                Widget widget = getWidget(attributes);
                widget.generateLabel(contentHandler);
            } else if (localName.equals("repeater-widget-label")) {
                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")) {
                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

        } else if (inWidgetElement) {
            xmlCompiler.startElement(namespaceURI, localName, qName, attributes);
        } else if (namespaceURI.equals(Constants.WT_NS)) {
            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

        int formRowCount = repeater.getSize();
        for (int i = 0; i < formRowCount; i++) {
            Repeater.RepeaterRow thisRow = repeater.getRow(i);

            //TODO future might need data-conversion here
            Widget rowIdWidget = thisRow.getWidget(this.uniqueRowId);
            String rowIdValue = (String) rowIdWidget.getValue();

            if (rowIdValue != null) {
                //if rowIdValue != null --> iterate nodes to find match
                Iterator rowPointers =
                    repeaterContext.iteratePointers(this.rowPath);
View Full Code Here

                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.length() == 0) {
                    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.length() == 0) {
            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

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.