public void afterComponentAttached(Component comp, Page page) { if (comp.getDesktop() != null) { // check if this component already binded Binder selfBinder = BinderUtil.getBinder(comp); if (selfBinder == null) { // check if parent exists any binder Binder parentBinder = BinderUtil.getBinder(comp, true); // post event to let the binder to handle binding later if (parentBinder != null && (parentBinder instanceof BinderImpl)) { // ZK-603, ZK-604, ZK-605 // register internal ON_BIND_INIT event listener to delay the timing of init and loading // bindings comp.addEventListener( 10000, BinderImpl.ON_BIND_INIT, new EventListener<Event>() { @Override public void onEvent(Event event) throws Exception { final Component comp = event.getTarget(); comp.removeEventListener(BinderImpl.ON_BIND_INIT, this); // ZK-611 have wrong binding on a removed treecell in a template // if it was detached, ignore it if (comp.getPage() == null) { return; } final Binder innerBinder = BinderUtil.getBinder(comp); if (innerBinder != null) { // it was already handled by innerBinder, ignore it return; } // ZK-1640 command send 2 wrong ViewModel // check if there any parent binder again, don't use out-side parentBinder, it is // not correct Binder binder = BinderUtil.getBinder(comp, true); if (binder == null) { return; } if (binder instanceof AnnotateBinder) { new AnnotateBinderHelper(binder).initComponentBindings(comp); } binder.loadComponent(comp, true); // [Dennis,20120925], this code was added when fixing issue zk-739, // but , inside binder.initComponentBindings, it shall do this already, I am not // sure why. if (comp.getAttribute(BinderImpl.VAR) != null) BinderUtil.markHandling(comp, binder); } }); // post ON_BIND_INIT event Events.postEvent(new Event(BinderImpl.ON_BIND_INIT, comp)); } } } }
/*package*/ void registerLoadEvents(Component comp) { if (isLoadable()) { // bug 1804356 if (_loadWhenEvents != null) { for (String expr : _loadWhenEvents) { final Object[] objs = ComponentsCtrl.parseEventExpression(comp, expr, comp, false); // objs[0] component, objs[1] event name final Component target = (Component) objs[0]; final String evtname = (String) objs[1]; if (target == null) { throw new NullPointerException("component not found , expr is " + expr); } LoadEventListener listener = (LoadEventListener) target.getAttribute("zk.LoadEventListener." + evtname); if (listener == null) { listener = new LoadEventListener(); target.setAttribute("zk.LoadEventListener." + evtname, listener); target.addEventListener(1000, evtname, listener); } listener.addDataTarget(this, comp); } } if (_loadAfterEvents != null) { for (String expr : _loadAfterEvents) { final Object[] objs = ComponentsCtrl.parseEventExpression(comp, expr, comp, false); // objs[0] component, objs[1] event name final Component target = (Component) objs[0]; final String evtname = (String) objs[1]; LoadAfterEventListener listener = (LoadAfterEventListener) target.getAttribute("zk.LoadAfterEventListener." + evtname); if (listener == null) { listener = new LoadAfterEventListener(); target.setAttribute("zk.LoadAfterEventListener." + evtname, listener); target.addEventListener(evtname, listener); target.addEventListener(evtname + "LoadAfter", listener); } listener.addDataTarget(this, comp); } } } }
/*package*/ void registerSaveEvents(Component comp) { if (isSavable()) { // bug 1804356 if (_saveWhenEvents != null) { for (String expr : _saveWhenEvents) { final Object[] objs = ComponentsCtrl.parseEventExpression(comp, expr, comp, false); // objs[0] component, objs[1] event name final Component target = (Component) objs[0]; final String evtname = (String) objs[1]; SaveEventListener listener = (SaveEventListener) target.getAttribute("zk.SaveEventListener." + evtname); if (listener == null) { listener = new SaveEventListener(); target.setAttribute("zk.SaveEventListener." + evtname, listener); target.addEventListener(1000, evtname, listener); } listener.addDataTarget(this, comp); } } if (_saveAfterEvents != null) { for (final Iterator it = _saveAfterEvents.iterator(); it.hasNext(); ) { final String expr = (String) it.next(); final Object[] objs = ComponentsCtrl.parseEventExpression(comp, expr, comp, false); // objs[0] component, objs[1] event name final Component target = (Component) objs[0]; final String evtname = (String) objs[1]; SaveAfterEventListener listener = (SaveAfterEventListener) target.getAttribute("zk.SaveAfterEventListener." + evtname); if (listener == null) { listener = new SaveAfterEventListener(); target.setAttribute("zk.SaveAfterEventListener." + evtname, listener); target.addEventListener(evtname, listener); target.addEventListener(evtname + "SaveAfter", listener); } listener.addDataTarget(this, comp); } } } }
public DesktopEventQueue() { _dummyTarget.addEventListener(ON_QUEUE, new QueueListener()); }
public void afterComponentAttached(Component comp, Page page) { if (comp.getDesktop() != null) { // check if this component already binded Binder selfBinder = BinderUtil.getBinder(comp); if (selfBinder == null) { // check if parent exists any binder Binder parentBinder = BinderUtil.getBinder(comp, true); // post event to let the binder to handle binding later if (parentBinder != null && (parentBinder instanceof BinderImpl)) { // ZK-603, ZK-604, ZK-605 // register internal ON_BIND_INIT event listener to delay the timing of init and loading // bindings comp.addEventListener( 10000, BinderImpl.ON_BIND_INIT, new EventListener<Event>() { public void onEvent(Event event) throws Exception { final Component comp = event.getTarget(); comp.removeEventListener(BinderImpl.ON_BIND_INIT, this); // ZK-611 have wrong binding on a removed treecell in a template // if it was detached, ignore it if (comp.getPage() == null) { return; } final Binder innerBinder = BinderUtil.getBinder(comp); if (innerBinder != null) { // it was already handled by innerBinder, ignore it return; } // ZK-1640 command send 2 wrong ViewModel // check if there any parent binder again, don't use out-side parentBinder, it is // not correct Binder binder = BinderUtil.getBinder(comp, true); if (binder == null) { return; } // ZK-1699 Performance issue ZK-Bind getters are called multiple times // check if it is handling, if yes then skip to evaluate it. if (getExtension().isLifeCycleHandling(comp)) { return; } if (binder instanceof AnnotateBinder) { new AnnotateBinderHelper(binder).initComponentBindings(comp); } // ZK-1699, mark the comp and it's children are handling. // note:mark handing before load, because of some load will change(create or // reset) the children structure // (consider F00769.zul if you bind to tree open , it will load children in // loadComponent) getExtension().markLifeCycleHandling(comp); binder.loadComponent(comp, true); // [Dennis,20120925], this code was added when fixing issue zk-739, // but , inside binder.initComponentBindings, it shall do this already, I am not // sure why. if (comp.getAttribute(BinderImpl.VAR) != null) BinderUtil.markHandling(comp, binder); } }); // post ON_BIND_INIT event Events.postEvent(new Event(BinderImpl.ON_BIND_INIT, comp)); } } } }