ZK Developer's Guide
ZK Developer's Guide
ZK Developer's Guide
- TAGS
- guide
- iknow.seforge.org
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Extending the Online Media Library<br />
Additionally for large data, it's not wise to present the user with a complete list of<br />
data. We present them only the first five records. Additionally, if we select a record<br />
from the pop-up list, the title of that record should appear in the input field, and<br />
the popup should close. The result should look like the following figure. For faster<br />
generation of test data, we have added a small functionality to generate such data.<br />
This feature is available with the link add testdata.<br />
Inside a bandbox, we can use the same components that are used outside a bandbox.<br />
Therefore, we use the listbox component for the result list. To fill the listbox with<br />
live data, we have to provide the data in ListModel (an instance of org.zkoss.<br />
zul.ListModel). Since we have more than one column, we have to implement<br />
an instance of org.zkoss.zul.ListitemRenderer. The implementation of this<br />
renderer is shown in the following listing.<br />
public class MediaListItemRenderer implements ListitemRenderer<br />
{<br />
public void render(Listitem item, Object data) throws Exception<br />
{<br />
if (data instanceof Media)<br />
{<br />
Media media = (Media) data;<br />
Listcell cell = null;<br />
// The id of the media<br />
cell = new Listcell();<br />
cell.setParent(item);<br />
cell.setLabel(media.getId());<br />
// The title of the Media<br />
cell = new Listcell();<br />
cell.setParent(item);<br />
cell.setLabel(media.getTitle());<br />
//Set the value of the item for the selection<br />
[ 80 ]