Use parameters in a conditional @command

asked 2014-06-20 15:53:33 +0800

oscarvalencia gravatar image oscarvalencia flag of Mexico
13 2

Hi, 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);

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?

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-06-20 17:22:58 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9

It has all to do with the lifecycle of the binder.
@Command and ${} are get on different times.

Read this documentation and see your solution in it.

Solution for you :

VM :

private boolean fromHere;

public void init(@ExecutionArgParam("isFromHere") boolean fromHere){
    this.fromHere = fromHere;

public boolean isFromHere() {
    return fromHere;

zul :

<button label="Save" onClick="@command(vm.fromHere ? 'save' : 'not')" />

Greetz chill.

link publish delete flag offensive edit


How do you do that if the command takes parameters? => Works in the 2nd part after the ":" .

WilliamB ( 2015-11-09 10:22:16 +0800 )edit

It will send the parameters to both commands but you doesn't need to fetch them

chillworld ( 2015-11-09 22:06:09 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2014-06-20 15:53:33 +0800

Seen: 53 times

Last updated: Jun 20 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More