Accessing Persistence Objects in ZUML Page"
From Documentation
(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…') |
m (correct highlight (via JWB)) |
||
Line 3: | Line 3: | ||
To access persistence objects in ZUML page is simple, simply declare a persistence object, and uses it to get data from database. | To access persistence objects in ZUML page is simple, simply declare a persistence object, and uses it to get data from database. | ||
− | # Create a < | + | # Create a <code>event.zul</code> in the root directory of web development. (ex. <code>$myApp/event.zul</code>) |
<source lang="xml" > | <source lang="xml" > | ||
Line 31: | Line 31: | ||
</source> | </source> | ||
− | # Open a browser and visit the ZUML page. (ex. < | + | # Open a browser and visit the ZUML page. (ex. <code>http://localhost:8080/event/event.zul</code>) |
{{ ZKDevelopersGuidePageFooter}} | {{ ZKDevelopersGuidePageFooter}} |
Latest revision as of 10:38, 19 January 2022
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.
- 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>
- Open a browser and visit the ZUML page. (ex.
http://localhost:8080/event/event.zul
)