datapointer-basics.lzx

<canvas debug="true" width="100%">
    <dataset name="ds" src="./shareddata/contacts_full.xml"/>
    <datapointer name="dp"/>

    <window title="Datapointer usage">
        <simplelayout/>
        <text fontstyle="bold" fontsize="15">Outputs of these buttons should display in the Debugger window</text>
        <button text="Show value of first name of the first &lt;person/&gt; node">
            <handler name="onclick">
                dp.setAttribute("xpath","ds:/addressbook/contacts/person[1]");
                //dp.setXPath("ds:/addressbook/contacts/person[1]");
                Debug.debug("%w", dp.getNodeAttribute('firstname'));
            </handler>

        </button>

        <button text="Show the full name of the owner of the address book.">
            <handler name="onclick">
                 dp.setAttribute("xpath","ds:/addressbook/metainformation/addressbookowner[1]/");
                 Debug.debug("%w %w", dp.getNodeAttribute('firstname'), dp.getNodeAttribute('lastname'));
            </handler>
            
        </button>
        <button text="Show total of &lt;person/&gt; nodes?">
            <handler name="onclick">
                 dp.setAttribute("xpath","ds:/addressbook/contacts");
                 Debug.debug("%w", dp.getNodeCount());
            </handler>
            
        </button>

        <button text="Show the value of the lastname of the 2nd node">
            <handler name="onclick">
                dp.setAttribute("xpath","ds:/addressbook/contacts/person[2]");
                Debug.debug("%w", dp.getNodeAttribute('firstname'));
            </handler>
            
        </button>
        <button text="Capitalize the firstname of the 2nd node">
            <handler name="onclick">
                dp.setAttribute("xpath","ds:/addressbook/contacts/person[2]");
                Debug.debug("BEFORE %w", dp.getNodeAttribute('firstname'));
                dp.setNodeAttribute('firstname',dp.getNodeAttribute('firstname').toUpperCase()) ;
                Debug.debug("AFTER %w", dp.getNodeAttribute('firstname'));
            </handler>
            
        </button>
    </window>
</canvas>
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
* Copyright 2007, 2008 Laszlo Systems, Inc.  All Rights Reserved.                   *
* Use is subject to license terms.                                            *
* X_LZ_COPYRIGHT_END ****************************************************** -->

Cross References

Named Instances