package org.zkoss.zk6support; import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.ContextParam; import org.zkoss.bind.annotation.ContextType; import org.zkoss.bind.annotation.NotifyChange; import org.zkoss.zk.ui.*; import org.zkoss.zk.ui.event.*; import org.zkoss.zk.ui.util.*; import org.zkoss.zk.ui.ext.*; import org.zkoss.zk.au.*; import org.zkoss.zk.au.out.*; import org.zkoss.zul.*; public class ViewModel { private String whereIsFocus = "I don't know where is focus"; public ViewModel() { } public String getWhereIsFocus() { return this.whereIsFocus; } @Command @NotifyChange("whereIsFocus") public void showWhereIsFocus(@ContextParam(ContextType.TRIGGER_EVENT) Event event) { System.out.println("Event received"); if(Events.ON_OPEN.equals(event.getName())) { OpenEvent e = (OpenEvent) event; if(e.isOpen()) { System.out.println("bandbox is open"); this.whereIsFocus = "focus is in bandbox"; } else { System.out.println("bandbox is NOT open"); this.whereIsFocus = "I don't know where is focus"; } } if(Events.ON_BLUR.equals(event.getName())) { System.out.println("ON_BLUR"); this.whereIsFocus = "I don't know where is focus"; } else if (Events.ON_FOCUS.equals(event.getName())) { System.out.println("ON_FOCUS"); this.whereIsFocus = "focus is in bandbox"; } } }