Yes, you can do this in MVVM too.
So, let's start from the beginning.
You need to connect some components, as in the answer you repeat :
@Wire("disable")
private List<Disable> allToDisable;
private boolean disable;
Secondly, the implementation of AfterCompose to disable and Init to check the status.
In regular MVVM, you almost never need to use it @AfterCompose, but when you need to connect to such solutions, you will need it.
@Init
public void init() {
disable = checkForGuest();
}
@AfterCompose
public void afterCompose(@ContextParam(ContextType.VIEW) Component view) {
Selectors.wireComponents(view, this, false);
disableAll(disable);
}
private void disableAll(boolean disableStatus){
for(Disable d : allToDisable) {
d.setDisabled(disableStatus);
}
}
, , @Init , AfterCompose.
:
, @AfterCompose.
disable zul:
<checkbox disabled="@load(yourValue or vm.disabled)"/>
, 1 2 , .
:
, , .
.
@AfterCompose
public void afterCompose(@SelectorParam("*") Collection<Component> allToDisable, @ContextParam(ContextType.BINDER)Binder binder) {
for(Component comp : allToDisable) {
if (comp instanceof Disable) {
((Disable)comp).setDisabled(disable);
binder.removeBindings(comp, "disabled");
}
}
}
** : **
, @Wire("disable") , ZK Fiddle.
, , @Wire, @SelectorParam, , Selectors.
@Wire @SelectorParam, .
, , disable, , .
, -, disabled .
, Binder @ContextParam.
, binder.removeBindings(Component, String);.
, binder.removeBindings(Component);, .
( , Textbox, )