0

call @command from java

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

Mavr gravatar image Mavr
0

I have page:

  <window title="${c:l('Bill')}" border="normal" closable="true" width="100%"
            action="show: slideDown;hide: slideUp" position="center,center"
            apply="org.zkoss.bind.BindComposer"
             viewModel="@id('vm') @init('com.testpkg.ctrl.FormSelectCtrl')"
             onClose="@command('CloseWin')"
             mode="overlapped"
            >
<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)" /> 
</div                   
        </window>

Event onOpen work.

Can I do, call Bind command from composer?

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

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

delete flag offensive retag edit

Comments

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
0

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:

@Command
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() {

        @Override
        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
0

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

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

You can call a command from java :

Binder.postCommand(String, Map)

The binder you can get like @gediminas already showed :

@Command
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

Follow
1 follower

RSS

Stats

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

Seen: 73 times

Last updated: Nov 06 '14

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