Sunday, March 30, 2014

ZK MVVM Command Data -- Loose Coupling More


Introduction

ZK MVVM already support Parameter of Command, it slightly increased the coupling since it bind the data with "parameter names", means you need to update both .zul and .java files if you want to change the naming.

This article describe a way to reduce the coupling, it bind the data with event name (instead of parameter names) with a custom component tag and retrieve command data by EventInterceptor.

Note:
Please ignore the implementation detail when you look into this sample, they are not the important part here and can be replaced by any other implementation (e.g. implemented by ZK MVVM mechanism itself in the future).
The only key point is "bind data with event name instead of parameter names".

Pre-request

ZK Create Helper Tag to Make Programmer Happier

Demo



Program

index.zul

TestVM.java

Item.java

Cparam.java

ComponentParameterInterceptor.java

zk.xml

lang-addon.xml

Download

Full project at github

Demo Flash

No comments:

Post a Comment