Package org.apache.cocoon.forms.formmodel

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


        JXPathBindingBase[] childBindings = this.identityBinding.getChildBindings();
        if (childBindings != null) {
            int size = childBindings.length;
            for (int i = 0; i < size; i++) {
                String fieldId = ((ValueJXPathBinding) childBindings[i]).getFieldId();
                Widget widget = row.lookupWidget(fieldId);
                Object value = widget.getValue();
                identity.add(value);
            }
        }
        return identity;
    }
View Full Code Here


    //---------------------------------------------------------------------------------------------
    // Widget management
    //---------------------------------------------------------------------------------------------

    public Widget getWidgetForPath(TreePath path) {
        Widget result = (Widget)this.pathWidgets.get(path);
        if (result == null && !this.pathWidgets.containsKey(path)) {
            result = createWidgetForPath(path);
            if (result != null) {
                result.setAttribute("TreePath", path);
            }
            this.pathWidgets.put(path, result);
        }

        return result;
View Full Code Here

     *   child-widget that cannot be found.
     */
    protected Widget selectWidget(Widget parent, String id) {
        if (id == null) return parent;
       
        Widget childWidget = null;
       
        childWidget = parent.lookupWidget(id);
           
        if (childWidget == null) {
            String containerId = parent.getRequestParameterName();
View Full Code Here

    /**
     * Actively performs the binding from the ObjectModel wrapped in a jxpath
     * context to the CForms-form-widget specified in this object.
     */
    public void doLoad(Widget frmModel, JXPathContext jxpc) throws BindingException {
        Widget widget = selectWidget(frmModel, 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) {
                ConversionResult conversionResult = convertor.convertFromString((String)value, convertorLocale, null);
                if (conversionResult.isSuccessful())
                    value = conversionResult.getResult();
                else
                    value = 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 CForms-form to the ObjectModel
     * wrapped in a jxpath context
     */
    public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException {
        Widget widget = selectWidget(frmModel, 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.getRequestParameterName(), e);
                }
            }
            if (subContext != null) {
                this.updateBinding.saveFormToModel(frmModel, subContext);
            }
View Full Code Here

     * @param frmModel the narrowed widget-scope from the parent binding
     * @param jxpc the narrowed jxpath context from the parent binding
     * @throws BindingException when the wrapped CustomBinding fails
     */
    public void doLoad(Widget frmModel, JXPathContext jxpc) throws BindingException {
        Widget selectedWidget = selectWidget(frmModel, this.widgetId);
        JXPathContext context = jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
       
        this.wrappedBinding.loadFormFromModel(selectedWidget, context);
    }   
View Full Code Here

     * @param frmModel the narrowed widget-scope from the parent binding
     * @param jxpc the narrowed jxpath context from the parent binding
     * @throws BindingException when the wrapped CustomBinding fails
     */
    public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException {
        Widget selectedWidget = selectWidget(frmModel, this.widgetId);
        JXPathContext context = jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
       
        this.wrappedBinding.saveFormToModel(selectedWidget, context);
    }
View Full Code Here

        JXPathBindingBase[] childBindings = this.identityBinding.getChildBindings();
        if (childBindings != null) {
            int size = childBindings.length;
            for (int i = 0; i < size; i++) {
                String fieldId = ((ValueJXPathBinding)childBindings[i]).getFieldId();
                Widget widget = row.getChild(fieldId);
                Object value = widget.getValue();
                identity.add(value);
            }
        }
        return identity;
    }
View Full Code Here

     *
     * @param currentWidget
     * @param id
     */
    public Widget getWidget(Widget currentWidget, String path) {
        Widget result = currentWidget.lookupWidget(path);

        if (result != null) {
            return result;
        } else {
            throw new IllegalArgumentException("Widget '" + currentWidget +
View Full Code Here

                                               "' has no child named '" + path + "'");
        }
    }

    public Repeater getRepeater(Widget currentWidget, String id) {
        Widget child = getWidget(currentWidget, id);
        if (child instanceof Repeater) {
            return (Repeater)child;
        } else {
            throw new IllegalArgumentException("Widget '" + child + "' is not a repeater");
        }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.forms.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.