Some years ago i’ve started to use ZK5 for a new work. At first sight it was looking as another bloated framework. But just because we are using it in a totally wrong way.
Sometimes i get in touch with that old code and it makes me shiver.. ZK components was used in a wrong way also for the old version 5 of the framework. For example a simply Listbox was populated by hand using cycle to add its children. No MVC was used, no databinding. Nothing at all.
Now we are at version 8 of ZK. What is changed? Almost all. Well, you can always develop using MVC paradigm or using the “VB6 Like” development but you have to use MVVM to understand the real power of ZK.
Using MVVM will reduce the code almost of 70-80% of its size. Yes. You have read the right number. Do you want a quick example? Here it is:
<listbox id="list" model="@bind(vm.hugeList)" width="200px" height="540px">
<listhead>
<listheader label="Load On Demand" sort="auto" />
</listhead>
</listbox>
Imagine you want to populate a Lisbox with a list of users retrieved somewhere. You will have in the zul page the component definition and nothing else.
private ListModel<String> hugeList;
@Init
public void Init() {
hugeList = DBManager.FakeListModel(250000);
}
public ListModel<String> getHugeList() {
return hugeList;
}
What we have here? No more extends, no implements. Nothing. Except the @Init annotation that will do the work for us. When the zul page is loaded, the init() function will be called from ZK because is annotated as the init function. In the class instantation the class DBManager (it this case it is only a class example..) will load the data for us. And who populate the grid? ZK will do! Automatically for us since it is binded thru