0

ZK6 ViewModel how to send more than one command for the same event

asked 2012-03-14 20:40:13 +0800

madruga0315 gravatar image madruga0315 flag of Brazil
937 2 12

Hi *,

It's possible to trigger more than one command for the same event?

I'm looking for something like:

<button onClick="@command('save') @command('showDetail')" />

But it gives the error that only one command is available.

Thanks,
Madruga

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2012-03-16 14:18:26 +0800

madruga0315 gravatar image madruga0315 flag of Brazil
937 2 12

Anyone????

link publish delete flag offensive edit

answered 2012-03-18 10:53:32 +0800

ashishd gravatar image ashishd flag of Taiwan
1972 6

Hi madruga0315,
The docs says @Command({"commanName1", "commandName2"}) this should work. Have you tried comma separating command names?

link publish delete flag offensive edit

answered 2012-03-18 17:19:53 +0800

madruga0315 gravatar image madruga0315 flag of Brazil
937 2 12

Hi ashishd,

Thanks for the reply, but the javadocs states the Annotation for the Java part.

// Java
@Command({"save", "forceSave"})
void saveObject() { .. logic .. }

// zul
<button onClick="@command('save')"/>
<button onClick-"@command('forceSave')/>

So two different buttons will trigger two different commands, but their end point will be the same method on the java backend.

But what I'm looking for is one button on the zul part trigger two (or more) different commands that each will have it's on method on the backend. Something like

// JAVA
@Command('save')
void save() { ... logic ...}

@Command('showDetail') { .. logic .. }

// zul
<button id="btnSaveAndShowDetail" onClick="@command('save') @command('showDetail')" />

"But why don't you just call the showDetail method on the save method?"
Well that's because this is a simplification to show what I'm looking for =]

link publish delete flag offensive edit

answered 2012-03-19 10:22:56 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

@Madruga,
Currently, We don't allow trigger multiple command in zul in zkbind2 layer (it is relative to the validation lifecycle, which might/might not stop commands)
However, from the app controller, it could do this by call Binder.postCommand or Binder.sendCommand.

link publish delete flag offensive edit

answered 2012-04-11 01:07:56 +0800

madruga0315 gravatar image madruga0315 flag of Brazil
937 2 12

Hi Dennis,

Thanks for the tip, but we re-organized our app so now we have a normal command and a global command.
Works great.

Thanks for the help.
Regards - Madruga

link publish delete flag offensive edit
Your reply
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

Follow

RSS

Stats

Asked: 2012-03-14 20:40:13 +0800

Seen: 406 times

Last updated: Apr 11 '12

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