/** * Sends an event to the specified target. * * @param event The event to send. * @param target The target for the event. If the target is null, the event is sent to the page * in the current execution context. */ public static void send(Event event, BaseComponent target) { if (target != null) { target.fireEvent(event); } }
/** * Send an event to this component's registered event listeners. * * @param eventType Type of event to send. */ public void fireEvent(String eventType) { fireEvent(EventUtil.toEvent(eventType, this, null)); }
/** * Send an event to all the descendants of this component using a depth-first traversal. Event * propagation stops if any recipient invokes the <code>stopPropagation</code> method on the * event. * * @param event Event to send. * @param includeThis If true, include this component in the recipient chain. */ public void notifyDescendants(Event event, boolean includeThis) { for (BaseComponent child : children) { child.notifyDescendants(event, true); } if (includeThis && !event.isStopped()) { fireEvent(event); } }
/** * Send an event to all the ancestors of this component. Event propagation stops if any * recipient invokes the <code>stopPropagation</code> method on the event. * * @param event Event to send. * @param includeThis If true, include this component in the recipient chain. */ public void notifyAncestors(Event event, boolean includeThis) { BaseComponent next = includeThis ? this : getParent(); while (next != null && !event.isStopped()) { next.fireEvent(event); next = next.getParent(); } }
/** * Flushes this component's invocation queue. */ private void _flushQueue() { if (invocationQueue != null) { page.getSynchronizer().processQueue(invocationQueue); invocationQueue = null; } for (BaseComponent child : children) { child._flushQueue(); } onAttach(page); fireEvent("attach"); }
/** * Handle changes to published properties. If the old and new values are the same, no action is * taken. Otherwise, the client is notified of the new value (if syncToClient is true) and a * {@link PropertychangeEvent} is fired. * * @param propertyName The property name. * @param oldValue The old value. * @param newValue The new value. * @param syncToClient If true, notify client of change. * @return True if property value changed. */ protected boolean propertyChange(String propertyName, Object oldValue, Object newValue, boolean syncToClient) { if (areEqual(oldValue, newValue)) { return false; } if (syncToClient) { sync(propertyName, newValue); } if (this.hasEventListener(PropertychangeEvent.TYPE)) { fireEvent(new PropertychangeEvent(this, propertyName, oldValue, newValue)); } return true; }
/** * Destroys this component. */ public void destroy() { if (dead) { return; } onDestroy(); if (page != null) { page.registerComponent(this, false); } destroyChildren(); if (parent != null) { parent.children.remove(this, false, true); } else { invokeIfAttached("destroy"); } dead = true; fireEvent(new Event("destroy", this)); eventListeners.removeAll(); }