-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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
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
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)
Asked: 2013-02-05 12:10:33 +0800
Seen: 73 times
Last updated: Nov 06 '14
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