Package org.apache.cocoon.woody.formmodel

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


        }
    }

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


     * 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

    Widget delegate;
    ScriptableWidget formWidget;

    class ScriptableFormHandler implements FormHandler {
        public void handleEvent(WidgetEvent widgetEvent) {
            Widget src = widgetEvent.getSourceWidget();
            ScriptableWidget w = wrap(src);
            w.handleEvent(widgetEvent);
        }
View Full Code Here

    /**
     * Actively performs the binding from the ObjectModel wrapped in a jxpath
     * context to the Woody-form-widget specified in this object.
     */
    public void doLoad(Widget frmModel, JXPathContext jxpc) throws BindingException {
        Widget widget = frmModel.getWidget(this.fieldId);
        if (widget == null) {
            throw new BindingException("The widget with the ID [" + this.fieldId
                    + "] referenced in the binding does not exist in the form definition.");
        }

        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);
        }
    }
View Full Code Here

    /**
     * Actively performs the binding from the Woody-form to the ObjectModel
     * wrapped in a jxpath context
     */
    public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException {
        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

        }
    }

    public boolean has(String id, Scriptable start) {
        if (delegate != null) {
            Widget sub = delegate.getWidget(id);
            if (sub != null) {
                return true;
            }
        }
        return super.has(id, start);
View Full Code Here

        return super.has(index, start);
    }

    public Object get(String id, Scriptable start) {
        if (delegate != null && !(delegate instanceof Repeater)) {
            Widget sub = delegate.getWidget(id);
            if (sub != null) {
                return wrap(sub);
            }
        }
        return super.get(id, start);
View Full Code Here

            List list = new LinkedList();
            for (int i = 0; i < result.length; i++) {
                list.add(result[i]);
            }
            while (iter.hasNext()) {
                Widget widget = (Widget)iter.next();
                list.add(widget.getId());
            }
            result = list.toArray();
        }
        return result;
    }
View Full Code Here

        }
        return false;
    }

    public ScriptableWidget jsFunction_getWidget(String id) {
        Widget sub = delegate.getWidget(id);
        return wrap(sub);
    }
View Full Code Here

                    Object result = fun.call(cx, scope, thisObj, args);
                    index[i] = Context.toBoolean(result);
                }   
                for (int i = len-1; i >= 0; --i) {
                    if (index[i]) {
                        Widget row = repeater.getRow(i);
                        formWidget.deleteWrapper(row);
                        repeater.removeRow(i);
                    }
                }
            } else if (obj instanceof Number) {
                int index = (int)Context.toNumber(obj);
                if (index > 0 && index < repeater.getSize()) {
                    Widget row = repeater.getRow(index);
                    formWidget.deleteWrapper(row);
                    repeater.removeRow(index);
                }
            } else {
                //...
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.