Package org.apache.cocoon.forms.formmodel

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


    public Widget peekWidget() {
        return (Widget)this.widgetStack.peek();
    }

    public void popWidget() throws SAXException {
        Widget widget = (Widget)this.widgetStack.pop();
        boolean inUpdatedTemplate = ((Boolean)this.widgetStack.pop()).booleanValue();

        if (inUpdatedTemplate) {
            // Close the bu:replace
            endBuReplace(widget.getFullName());
        }
        if (widget instanceof Repeater) {
            this.labelStack.pop();
        }
    }
View Full Code Here


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

        if (result != null) {
            return result;
        }
        throw new FormsRuntimeException(currentWidget + " has no child named '" + path + "'", currentWidget.getLocation());
View Full Code Here

        }
        throw new FormsRuntimeException(currentWidget + " has no child named '" + path + "'", currentWidget.getLocation());
    }

    private Repeater getRepeater(Widget currentWidget, String id) {
        Widget child = getWidget(currentWidget, id);
        if (child instanceof Repeater) {
            return (Repeater)child;
        }
        throw new FormsRuntimeException(child + " is not a repeater", child.getLocation());
    }
View Full Code Here

    public void flushRoot() throws SAXException {
        ((RootBufferingPipe) pipeStack.pop()).flushRoot();
    }

    public void generateWidgetLabel(Widget widget, String id) throws SAXException {
        Widget widgetInst = getWidget(widget, id);
        if (widget instanceof Repeater) {
            widgetInst.generateLabel(this.cocoonConsumer);
        } else {
            AttributesImpl attrs = new AttributesImpl();
            attrs.addCDATAAttribute("id", widgetInst.getRequestParameterName());
            attrs.addCDATAAttribute("state", widgetInst.getCombinedState().getName());
            this.cocoonConsumer.startElement(FormsConstants.INSTANCE_NS, "field-label", FormsConstants.INSTANCE_PREFIX_COLON + "field-label", attrs);
            if (widgetInst.getCombinedState().isDisplayingValues()) {
                widgetInst.getDefinition().generateDisplayData(this.cocoonConsumer);
            }
            this.cocoonConsumer.endElement(FormsConstants.INSTANCE_NS, "field-label", FormsConstants.INSTANCE_PREFIX_COLON + "field-label");
        }
    }
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 = selectWidget(frmModel, 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;
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 {
View Full Code Here

    public Widget peekWidget() {
        return (Widget)this.widgetStack.peek();
    }
   
    public void popWidget() throws SAXException {
        Widget widget = (Widget)this.widgetStack.pop();
        boolean inUpdatedTemplate = ((Boolean)this.widgetStack.pop()).booleanValue();
       
        if (inUpdatedTemplate) {
            // Close the bu:replace
            endBuReplace(widget.getFullName());
        }
    }
View Full Code Here

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

        if (result != null) {
            return result;
        }
        throw new FormsRuntimeException(currentWidget + " has no child named '" + path + "'", currentWidget.getLocation());
View Full Code Here

        }
        throw new FormsRuntimeException(currentWidget + " has no child named '" + path + "'", currentWidget.getLocation());
    }

    private Repeater getRepeater(Widget currentWidget, String id) {
        Widget child = getWidget(currentWidget, id);
        if (child instanceof Repeater) {
            return (Repeater)child;
        }
        throw new FormsRuntimeException(child + " is not a repeater", child.getLocation());
    }
View Full Code Here

    public ComposedJXPathBindingBase getUpdateBinding() { return (ComposedJXPathBindingBase)updateBinding; }
    public Convertor getConvertor() { return convertor; }
    public Locale getLocale() { return convertorLocale; }

    public void doLoad(Widget frmModel, JXPathContext jctx) throws BindingException {
        Widget widget = selectWidget(frmModel, 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) {
                        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.");
                    }
                }

                list.add(value);
            }

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

        if (getLogger().isDebugEnabled()) {
            getLogger().debug("done loading values " + this);
        }
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.