Package org.apache.cocoon.forms.formmodel

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


        }
        return result;
    }

    private void deleteRow(Repeater repeater, int index) {
        Widget row = repeater.getRow(index);
        ScriptableWidget s = wrap(row);
        s.notifyRemoveRow();
        formWidget.deleteWrapper(row);
        repeater.removeRow(index);
    }
View Full Code Here


        }
        return false;
    }

    public ScriptableWidget jsFunction_getChild(String id) {
        Widget sub = null;
        if (delegate instanceof ContainerWidget)
            sub = ((ContainerWidget)delegate).getChild(id);
        return wrap(sub);
    }
View Full Code Here

            sub = ((ContainerWidget)delegate).getChild(id);
        return wrap(sub);
    }

    public ScriptableWidget jsFunction_lookupWidget(String id) {
        Widget sub = null;
        sub = delegate.lookupWidget(id);
        return wrap(sub);
    }
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

        } else if (delegate instanceof MultiValueField) {
            if (id.equals("length")) {
                return true;
            }
        } else if (delegate != null) {
            Widget sub = delegate.lookupWidget(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.lookupWidget(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.lookupWidget(id);
            if (sub instanceof Field) {
                Field field = (Field)sub;
                value = unwrap(value);
                if (value instanceof Double) {
                    // make cforms accept a JS Number
View Full Code Here

        }
    }

    public String getSubmitId() {
     
        Widget widget = this.form.getSubmitWidget();
        // Can be null on "normal" submit
        return  widget == null ? null : widget.getId();
    }
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

    private void endBuReplace(String id) throws SAXException {
        this.cocoonConsumer.endElement(BrowserUpdateTransformer.BU_NSURI, "replace", "bu:replace");
    }

    protected boolean pushWidget(String path, boolean unused) throws SAXException {
        Widget parent = peekWidget();
        if (path == null || path.length() == 0) {
            throw new FormsRuntimeException("Missing 'id' attribute on template instruction");
        }
        Widget widget = parent.lookupWidget(path);
        if (widget == null) {
            throw new FormsRuntimeException(parent + " has no child named '" + path + "'", parent.getLocation());
        }

        String id = widget.getFullName();
        // Is there an updated widget at a higher level in the template?
        boolean inUpdatedTemplate = ((Boolean)widgetStack.peek(1)).booleanValue();

        boolean display;

        if (ajaxRequest) {
            // An Ajax request. We will send partial updates
            if (inUpdatedTemplate) {
                // A parent widget has been updated: redisplay this one also
                display = true;
            } else if (this.updatedWidgets.contains(id)) {
                // Widget has been updated. We are now in an updated template section,
                // and widgets have to be surrounded with <bu:replace>
                inUpdatedTemplate = true;
                display = true;
            } else if (this.childUpdatedWidgets.contains(id)) {
                // A child need to be updated
                display = true;
            } else {
                // Doesn't need to be displayed
                display = false;
            }
        } else {
            // Not an ajax request
            if (ajaxTemplate) {
                // Surround all widgets with <bu:replace>, which the bu tranformer will use to check structure
                // consistency and add an id attribute to its child elements.
                inUpdatedTemplate = true;
            }
            // Display the widget
            display = true;
        }

        if (display) {
            // Widget needs to be displayed, but does it actually allows it?
            if (widget.getState().isDisplayingValues()) {
                if (inUpdatedTemplate) {
                    // Updated part of an Ajax template: surround with <bu:replace>
                    startBuReplace(id);
                }
            } else {
                if (ajaxTemplate) {
                    // Generate a placeholder, so that the page can be updated later
                    startBuReplace(id);
                    AttributesImpl attrs = new AttributesImpl();
                    attrs.addCDATAAttribute("id", widget.getRequestParameterName());
                    attrs.addCDATAAttribute("state", widget.getCombinedState().getName());
                    this.cocoonConsumer.startElement(FormsConstants.INSTANCE_NS, "placeholder", FormsConstants.INSTANCE_PREFIX_COLON + "placeholder", attrs);
                    // check if the parent wants to update the label of the child widget
                    if (ajaxRequest && ((Boolean)this.labelStack.peek()).booleanValue()) {
                        Map style = new HashMap(1);
                        style.put("update-label", "true");
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.