O'Reilly logo

ZK Developer's Guide by Markus Stauble, Hans-Jurgen Schumacher, Jurgen Schumacher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extending Add and Update

The add media (add-media.zul) and update media (update-media,zul) features have so far been implemented as two different pages. These pages are very similar, and therefore, we can merge them. The only difference is that in the case of an update we load the data, and for adding we create a new instance. The simplest way is to extend the page with a mode parameter. The new page can have the name add-update-media.zul.

The first change is in the index.zul page:

<toolbarbutton label="Add a new media">
<attribute name="onClick">
Sessions.getCurrent().setAttribute("media.mode", "add");
Executions.sendRedirect("add-update-media.zul");
</attribute>
</toolbarbutton>

Additionally we have to extend com.packtpub.zk.media.view.MediaListItemRenderer ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required