/** * Adds an event forward. An event forward forwards an event of the specified type received by * this component to another component, optionally with a different event type. * * @param eventType The event type to forward. * @param target The target for the forwarded event. * @param forwardType The type of the forwarded event. If null, the original event type is used. */ public void addEventForward(String eventType, BaseComponent target, String forwardType) { addEventListener(eventType, createForwardListener(eventType, target, forwardType)); }
public void registerComponent(BaseComponent component, boolean register) { if (register) { component.addEventListener("keypress", this); } else { component.removeEventListener("keypress", this); } } }
/** * Wires onEvent style event handlers. * * @param instance Controller to be wired. * @param component The component that triggers the event. * @param onHandlers The map of onEvent style handlers. */ public static void wire(Object instance, BaseComponent component, Map<String, String> onHandlers) { for (Entry<String, String> entry : onHandlers.entrySet()) { String eventType = entry.getKey(); String methodName = entry.getValue(); Class<? extends Event> eventClass = EventUtil.getEventClass(eventType); Method handler = ReflectionUtils.findMethod(instance.getClass(), methodName, eventClass); handler = handler == null ? ReflectionUtils.findMethod(instance.getClass(), methodName) : handler; ComponentException.assertTrue(handler != null, "A suitable event handler named \"%s\" could not be found", methodName); EventListener eventListener = new EventListener(instance, handler); component.addEventListener(eventType, eventListener); } }
/** * Sets the referenced component, removing any previous reference. * * @param component The referenced component. * @return True if the referenced component changed. */ public boolean setReference(T component) { if (component != this.component) { if (component != null) { component.validatePage(BaseComponent.this.page); component.addEventListener("destroy", this); } removeReference(); this.component = component; return true; } return false; }
/** * Creates an action listener. * * @param component Component receiving the event. * @param action Action to be invoked upon receipt of the event. * @param eventName The name of the event. */ protected ActionListener(BaseComponent component, IAction action, String eventName) { this.component = component; this.action = action; this.eventName = eventName; this.attrName = getAttrName(eventName); ActionUtil.removeAction(component, eventName); component.addEventListener(eventName, this); component.setAttribute(attrName, this); }
addEventListener(eventName, (IEventListener) value); return; addEventListener(eventName, (event) -> { if (script.getPage() == null) { script.setParent(getPage());
/** * Override the doAfterCompose method to set references to the application context and the * framework and register the controller with the framework. * * @param comp BaseComponent associated with this controller. */ @Override public void afterInitialized(BaseComponent comp) { root = (BaseUIComponent) comp; this.comp = root; comp.setAttribute(Constants.ATTR_COMPOSER, this); comp.addEventListener(ThreadEx.ON_THREAD_COMPLETE, threadCompletionListener); appContext = SpringUtil.getAppContext(); appFramework = FrameworkUtil.getAppFramework(); eventManager = EventManager.getInstance(); initialize(); }
} else { for (String type : types) { component.addEventListener(type, new EventListener(instance, method), annotation.syncToClient());