Package org.apache.commons.jxpath

Examples of org.apache.commons.jxpath.Pointer


    public void doLoad(Widget frmModel, JXPathContext jctx) {
        if (this.loadScript != null) {
            Widget widget = frmModel.getWidget(this.id);
   
            // Move to widget context
            Pointer pointer = jctx.getPointer(this.path);
   
            // FIXME: remove this ugly hack and get the request from the
            // Avalon context once binding builder are real components
            Map objectModel = CocoonComponentManager.getCurrentEnvironment().getObjectModel();

            try {
                Map values = new HashMap(3);
                values.put("widget", widget);
                values.put("jxpathPointer", pointer);
                if (pointer.getNode() != null) {
                    values.put("jxpathContext", jctx.getRelativeContext(pointer));
                }

                JavaScriptHelper.execScript(this.loadScript, values, objectModel);
   
View Full Code Here


                throw new SAXException("Cannot evaluate expression {"
                                       + this.data + "}", e);
            }

            if (execute) {
                Pointer ptr = context.getContextPointer();
                JXPathContext ctx = context.getRelativeContext(ptr);
                VariableScope scp = new VariableScope(ctx);
                Iterator iterator = this.iterator();
                while(iterator.hasNext()) {
                    ((Event)iterator.next()).process(runtime, ctx);
View Full Code Here

        if (this.clearOnLoad) {
            repeater.removeRows();
        }

        // Find the location of the repeater data.
        Pointer repeaterPointer = jctx.getPointer(this.repeaterPath);

        // Check if there is data present.
        //
        // (Otherwise, should we check the leniency config option
        // to decide whether to be silent or throw an exception?)
        if (repeaterPointer != null) {

            // Narrow to repeater context.
            JXPathContext repeaterContext = jctx.getRelativeContext(repeaterPointer);

            // Build a jxpath iterator for the repeater row pointers.
            Iterator rowPointers = repeaterContext.iteratePointers(this.rowPath);

            // Iterate through the rows of data.
            int rowNum = 0;
            while (rowPointers.hasNext()) {

                // Get or create a row widget.
                Repeater.RepeaterRow thisRow;
                if (repeater.getSize() > rowNum) {
                    thisRow = repeater.getRow(rowNum);
                } else {
                    thisRow = repeater.addRow();
                }
                rowNum++;

                // Narrow to the row context.
                Pointer rowPointer = (Pointer) rowPointers.next();
                JXPathContext rowContext = repeaterContext.getRelativeContext(rowPointer);

                // If virtual rows are requested, place a deep clone of the row data
                // into a temporary node, and narrow the context to this virtual row.
                //
                // (A clone of the data is used to prevent modifying the source document.
                // Otherwise, the appendChild method would remove the data from the source
                // document.  Is this protection worth the penalty of a deep clone?)
                //
                // (This implementation of virtual rows currently only supports DOM
                // bindings, but could easily be extended to support other bindings.)

                if (virtualRows == true) {
                    Node repeaterNode = (Node)repeaterPointer.getNode();
                    Node virtualNode = repeaterNode.getOwnerDocument().createElementNS(null, "virtual");
                    Node clone = ((Node)rowPointer.getNode()).cloneNode(true);
                    virtualNode.appendChild(clone);
                    rowContext = JXPathContext.newContext(repeaterContext, virtualNode);
                }

                // Finally, perform the load row binding.
View Full Code Here

                    // Iterate through the repeater rows.
                    for (int i = 0; i < repeater.getSize(); i++) {

                        // Narrow to the repeater row context.
                        Pointer rowPointer = repeaterContext.getPointer(this.rowPathInsert);
                        JXPathContext rowContext = repeaterContext.getRelativeContext(rowPointer);

                        // Variables used for virtual rows.
                        // They are initialized here just to keep the compiler happy.
                        Node rowNode = null;
View Full Code Here

        while(iter.hasNext()) {
            String stringValue = "";
            Object label = null;

            // Get a context on the current item
            Pointer ptr = (Pointer)iter.next();
            if (ptr.getValue() != null) {
                JXPathContext itemCtx = ctx.getRelativeContext(ptr);

                // Get the value as a string
                Object value = itemCtx.getValue(this.valuePath);
View Full Code Here

    /**
     * Actively performs the binding from the ObjectModel wrapped in a jxpath
     * context to the CocoonForm.
     */
    public void doLoad(Widget frmModel, JXPathContext jxpc) throws BindingException {
        Pointer ptr = jxpc.getPointer(this.xpath);
        if (ptr.getNode() != null) {
            JXPathContext subContext = jxpc.getRelativeContext(ptr);
            super.doLoad(frmModel, subContext);
            if (getLogger().isDebugEnabled())
                getLogger().debug("done loading " + toString());
        } else {
View Full Code Here

    /**
     * Actively performs the binding from the CocoonForm to the ObjectModel
     * wrapped in a jxpath context.
     */
    public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException {
        Pointer ptr = jxpc.getPointer(this.xpath);
        if (ptr.getNode() == null) {
            jxpc.createPath(this.xpath);
            // Need to recreate the pointer after creating the path
            ptr = jxpc.getPointer(this.xpath);
        }
        JXPathContext subContext = jxpc.getRelativeContext(ptr);
View Full Code Here

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

        if (values != null) {
            // first update the values
            for (int i = 0; i < values.length; i++) {
                String path = this.rowPath + '[' + (i+1) + ']';
                Pointer rowPtr = multiValueContext.createPath(path);

                Object value = values[i];
                if (value != null && convertor != null) {
                    value = convertor.convertToString(value, convertorLocale, null);
                }

                rowPtr.setValue(value);
            }

            // now perform any other bindings that need to be performed when the value is updated
            this.updateBinding.saveFormToModel(frmModel, multiValueContext);
View Full Code Here

    public void doLoad(Widget frmModel, JXPathContext jctx) {
        if (this.loadScript != null) {
            Widget widget = selectWidget(frmModel,this.id);
   
            // Move to widget context
            Pointer pointer = jctx.getPointer(this.path);
   
            // FIXME: remove this ugly hack and get the request from the
            // Avalon context once binding builder are real components
            Map objectModel = CocoonComponentManager.getCurrentEnvironment().getObjectModel();

            try {
                Map values = new HashMap(3);
                values.put("widget", widget);
                values.put("jxpathPointer", pointer);
                if (pointer.getNode() != null) {
                    values.put("jxpathContext", jctx.getRelativeContext(pointer));
                }

                JavaScriptHelper.execScript(this.loadScript, values, objectModel);
   
View Full Code Here

TOP

Related Classes of org.apache.commons.jxpath.Pointer

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.