December 17, 2014
Hot Topics:

Ajax with the ZK Framework

  • June 1, 2006
  • By Michael Klaene
  • Send Email »
  • More Articles »

If you prefer in certain situations to handle event logic directly in your ZUML page, you can easily do so with the <zscript> element. There are virtually no limitations to what you can do in the zscript portion of a page. As an example, look at the following toolbar component for the main window:

                <toolbarbutton label="Contacts" onClick="showContacts()"/>

The onClick event method in this case will be written within a <zscript> element. The particular event handler displays a popup window with contact information for questions about student enrollment. Before it displays the window, however, it programmatically creates components and adds them to the window:

       void showContacts() {
            Label primaryContact = new Label();
            primaryContact .value="Primary: John Smith - (502) 545-1900";
            Label secondaryContact = new Label();
            secondaryContact .value="Secondary: Julie Stewart - (502) 545-1935";
            winAbout.appendChild(primaryContact );
            winAbout.appendChild(new Separator());
            winAbout.appendChild(secondaryContact);

            //Display window on top of main window.
            winAbout.doOverlapped();
        }

The window that displays contact information is also defined in index.zul:

    <window id="winAbout" visible="false" title="Contacts" closable="true" 
        border="normal" width="300px" height="100px">
    </window>

As previously mentioned, you can add several components and even several windows filled with child components in a single ZUML file, or you can break them up into separate files. Test the sample application and witness some of the features it provides, message boxes for example. Adding such functionality was trivial but can greatly improve the user experience.


Contacts popup window


Error! Course already appears in schedule


Confirmation before exit

I have only touched upon ZK's numerous features. The ZK site provides excellent documentation. I think you will find it worth your while to experiment with ZK and learn how to build Ajax web applications with minimal effort.

About the Author

Michael Klaene is a Senior Consultant with Sogeti LLC. He has spent over 9 years in Information Technology and is an experienced Systems Analyst, delivering solutions that involve numerous technologies, such as J2EE and .NET.





Page 2 of 2



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Rocket Fuel