updated to 2.5.0
View Pojo (Render Pojo)#
The view pojos are passive dataholder for the view. They are instantiated after all view data has been computed. All data needed for this objects should be passed in the constructor.
The exposed values are specified by the @ZExpose annotation.
recommended pattern#Normally render pojos are PASSIVE, view layer. That means they should not contain business logic, only data for display. render-pojos should NOT go to the database, access EJBs or do anything smart. Just VIEW data. Passive data-holders. Data is provided to them from the outside. render-pojos are somehow similar to Swing Models, but on a more coarse level. Normally a render-pojo contains data for many gui-controls.
if this is not enough#Nevertheless, it IS possible to use the same pojo for view and actions. Decide for yourself.
active views#since 2.5.0 it is possible to create active views by implementing the ZIActiveView interface. This is when you need views that access the data layer by themselves. Advantage: no change to the including view when you need more/othre data Disadvantage: separation is not clear anymore, reuse is harder, links/errorhandling. You should use this for ajax-style views that live in a div and only change that div-content.
ZIActiveView provides a beforeRendering callback, this is called before rendering and exposing the views fields. You should prepare the view data in this callback.