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 ...