I'm triying to use a conditional @command with an argument passed with Executions.createComponents, this is my java code:
Map data = new HashMap();
data.put("isFromHere", true);
modal = (Window) Executions.createComponents("root/to/window", null, data);
modal.doModal();
And in my zul page I'm trying to do this:
<button label="Save" onClick="@command(arg.isFromHere ? 'save' : 'not')" />
But every time arg.isFromHere is returning false, like the argument is not passed. But if I do this:
<button if="${arg.isFromHere}" label="Save" onClick="@command('save'" />
That does work fine! What means the arguments are getting to the zul page, but not working on conditional commands, Is there a way to make it work?
It has all to do with the lifecycle of the binder.
@Command
and ${arg.xxx}
are on different lifecycle.
Read this documentation and see your solution in it.
Solution for you :
private boolean fromHere;
@Init
public void init(@ExecutionArgParam("isFromHere") boolean fromHere){
this.fromHere = fromHere;
}
public boolean isFromHere() {
return fromHere;
}
<button label="Save" onClick="@command(vm.fromHere ? 'save' : 'not')" />