Accessing Persistence Objects in ZUML Page

From Documentation
Revision as of 04:42, 19 July 2010 by Char (talk | contribs) (Created page with '{{ZKDevelopersGuidePageHeader}} To access persistence objects in ZUML page is simple, simply declare a persistence object, and uses it to get data from database. # Create a <t…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Accessing Persistence Objects in ZUML Page


Stop.png This documentation is for an older version of ZK. For the latest one, please click here.


To access persistence objects in ZUML page is simple, simply declare a persistence object, and uses it to get data from database.

  1. Create a event.zul in the root directory of web development. (ex. $myApp/event.zul)
 <zk>
 <zscript><![CDATA[
 import java.util.Date;
 import java.text.SimpleDateFormat;
 import events.Event;
 import events.EventDAO;

 //fetch all allEvents from database
 List allEvents = new EventDAO().findAll();

 ]]></zscript>
 <listbox id="lbxEvents">                
     <listhead>
         <listheader label="Title" width="200px"/>
         <listheader label="Date" width="100px"/>
     </listhead>
     <listitem forEach="${allEvents}" value="${each}">
         <listcell label="${each.title}"/>
         <zscript>String datestr = new SimpleDateFormat("yyyy/MM/dd").format(each.date);</zscript>
         <listcell label="${datestr}"/>
     </listitem>
 </listbox>
 </zk>
  1. Open a browser and visit the ZUML page. (ex. http://localhost:8080/event/event.zul)


Last Update : 2010/07/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.