call @command from java

asked 2013-02-05 12:10:33 +0800

Mavr gravatar image Mavr

I have page:

  <window title="${c:l('Bill')}" border="normal" closable="true" width="100%"
            action="show: slideDown;hide: slideUp" position="center,center"
             viewModel="@id('vm') @init('com.testpkg.ctrl.FormSelectCtrl')"
<div viewModel="@id('vm') @init('com.testpkg.ctrl.mainCntr')" apply="org.zkoss.bind.BindComposer">
    <bandbox id="bill_dep" width="120px"                            mold="default" autodrop="false" onOpen="@command('opencat',comp=self)" /> 

Event onOpen work.

Can I do, call Bind command from composer?

     Bandbox bbx= new Bandbox();
     bbx.addEventListener(Events.ON_OPEN,new EventListener<Event>(){
     public void onEvent(Event arg0) throws Exception {

or bbx.setAttribute("onOpen",@command('opencat',comp=self)); don't work

delete flag offensive retag edit


Why you want to do this thing from Java code ? While you have easy way to do it in ZUL?

sjoshi ( 2013-02-05 12:37:36 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2014-11-06 17:44:06 +0800

gediminas gravatar image gediminas
39 3

Not sure if this is relevant for the original question, but one case when calling a command from Java would be useful is if you have a @Command method which shows a custom confirmation dialog (via Messagebox#show), and when the user clicks confirm, you want to invoke another command (and benefit from its @NotifyChange annotations).

This might be a possible pattern:

public void confirmCommitEdit(@ContextParam(ContextType.BINDER) Binder binder) {
    sendCommandIfConfirmed("categoryAdmin.confirm.save", binder, "commitEdit");

private static void sendCommandIfConfirmed(String messageKey, Binder binder, String commandName) {
    MessageUtils.confirmYesNo("categoryAdmin.confirm.cancel", new ConfirmationEventListener() {

        public void onConfirm() {
            binder.sendCommand(commandName, null);

In this example: MessageUtils wraps Messagebox#show and ConfirmationEventListener checks if Messagebox.YES or Messagebox.OK was passed as eventData and if so, invokes onConfirm

link publish delete flag offensive edit

answered 2014-11-06 18:10:30 +0800

chillworld gravatar image chillworld flag of Belgium
5357 4 9

You can call a command from java :

Binder.postCommand(String, Map)

The binder you can get like @gediminas already showed :

public void doSomething (@ContextParam(ContextType.BINDER) Binder binder)
link publish delete flag offensive 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: 2013-02-05 12:10:33 +0800

Seen: 69 times

Last updated: Nov 06 '14

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