private void notifyVMsgsChanged() { if (_validationMessages != null) { //ZK-722 Validation message is not clear after form binding loaded //defer the validation notify as possible Events.postEvent(-1, _dummyTarget, new Event(ON_VMSGS_CHANGED)); } }
/** Sends the event to the target, and processes it immediately. * @param target the target of the event (never null) * @since 5.0.4 */ public static void sendEvent(String name, Component target, Object data) { sendEvent(new Event(name, target, data)); }
/** Creates an instance of {@link Event} based on the specified request. */ public static Event getEvent(AuRequest request) { final String name = request.getCommand(); final Component comp = request.getComponent(); final Map<String, Object> data = request.getData(); //ZK-1847 should check whether data is empty or not if (data.isEmpty()) { return new Event(name, comp); } else if (data.containsKey("") && data.size() == 1) { //ZK-1812 extract value of ""-key, only if there is nothing else in the map final Object extractedData = data.get(""); if (extractedData == null) return new Event(name, comp); if (extractedData instanceof Collection) return new Event(name, comp, ((Collection<?>) extractedData).toArray()); return new Event(name, comp, extractedData); } return new Event(name, comp, data); }
/** Posts an instance of {@link Event} to the current execution * with the specified priority. * * <p>The posted events are processed from the higher priority to the * lower one. If two events are posted with the same priority, * the earlier the event being posted is processed earlier * (first-in-first-out). * * <p>The priority posted by posted by {@link #postEvent(Event)} is * 0. * Applications shall not use the priority higher than 10,000 and * lower than -10,000 since they are reserved for component * development. * * @param priority the priority of the event. * @since 3.0.7 */ public static final void postEvent(int priority, String name, Component target, Object data) { if (name == null || name.length() == 0 || target == null) throw new IllegalArgumentException("Name is empty or target is null."); postEvent(priority, new Event(name, target, data)); }
public void postCommand(String command, Map<String, Object> args) { checkInit(); final Event evt = new Event(ON_POST_COMMAND, _dummyTarget, new Object[] { command, args }); Events.postEvent(evt); }
/** * Echos an event to the specified target for timing purposes. * * @param target The component that will be the target of the echoed event. * @param tag The tag to be included in the log entry. * @param displayElapsed If true, the performance information will be sent to the display. * @param rt The time segment to be logged. */ public static void timeEcho(Component target, String tag, boolean displayElapsed, RequestTime rt) { monitorEvent(target, EVENT_TIME_ECHO, tag, displayElapsed); Event event = new Event(EVENT_TIME_ECHO, target, rt); Events.echoEvent(event); }
private static void doBindChildrenInFilter(Component[] shadows) { for (Component shadow : shadows) { if (shadow instanceof ShadowElement) { ShadowElement se = (ShadowElement) shadow; if (!se.getDistributedChildren().isEmpty() || !((ShadowElementCtrl) se).isDynamicValue()) continue; List<Component> children = shadow.getChildren(); if (children.size() == 0) { Events.sendEvent(new Event("onBindInit", (Component) se)); Events.sendEvent(new Event("onBindingReady", (Component) se)); children = shadow.getChildren(); } if (children.size() > 0) doBindChildrenInFilter(children.toArray(new Component[children.size()])); } } } }
/** Handles an AU request. It is invoked internally. * * <p>Default: it handles echo and setAttr, and it converts other request * to an event (by {@link Event#getEvent}) and then posts the event * (by {@link Events#postEvent}). * * <p>Application developer can plug the custom service to handle * the AU request by {@link #setAuService}. * @since 5.0.0 * @see #setAuService */ public void service(AuRequest request, boolean everError) { final String cmd = request.getCommand(); if ("echo".equals(cmd)) { final List data2 = (List) request.getData().get(""); Events.postEvent(new Event((String) data2.get(0), this, data2.size() > 1 ? AuEcho.getData(this, data2.get(1)) : null)); } else if ("setAttr".equals(cmd)) { final List data2 = (List) request.getData().get(""); updateByClient((String) data2.get(0), data2.get(1)); } else Events.postEvent(Event.getEvent(request)); }
/** <p>This implementation forward request to onAcegiLogin command.</p> */ public void commence(ServletRequest request, ServletResponse response, AuthenticationException authException) throws IOException, ServletException { final Component comp = (Component) request.getAttribute(ZkEventExceptionFilter.COMPONENT); //remember the original event that cause the security login in session final Event evt = (Event) request.getAttribute(ZkEventExceptionFilter.EVENT); ((HttpServletRequest) request).getSession().setAttribute(ZkEventExceptionFilter.EVENT, evt); if (!comp.isListenerAvailable(ON_ACEGILOGIN, true)) { final EventListener<Event> listener = new ShowWindowEventListener<Event>(); comp.setAttribute(ON_ACEGILOGIN, listener); comp.addEventListener(ON_ACEGILOGIN, listener); } final String url = getLoginFormUrl(); Events.postEvent(new Event(ON_ACEGILOGIN, comp, url != null ? url : "~./acegilogin.zul")); } }
public void onEvent(ClickEvent event) throws Exception { final Button btn = event.getButton(); _listener.onEvent(new Event(event.getName(), event.getTarget(), btn != null ? btn.id : -1)); }
public void handle(ServletRequest request, ServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { // Put exception into request scope (perhaps of use to a view) ((HttpServletRequest) request).setAttribute(AccessDeniedHandlerImpl.ACEGI_SECURITY_ACCESS_DENIED_EXCEPTION_KEY, accessDeniedException); final Component comp = (Component) request.getAttribute(ZkEventExceptionFilter.COMPONENT); if (!comp.isListenerAvailable(ON_ACCESSDENIED, true)) { final EventListener<Event> listener = new ShowWindowEventListener<Event>(); comp.setAttribute(ON_ACCESSDENIED, listener); comp.addEventListener(ON_ACCESSDENIED, listener); } final String url = getErrorPage(); Events.postEvent(new Event(ON_ACCESSDENIED, comp, url != null ? url : "~./accessDenied.zul")); } }
/** * Converts an echo response to the equivalent event. * * @param echo An echo response. * @return Event as it would be echoed by client. */ private Event toEvent(AuEcho echo) { Object[] raw = echo.getRawData(); Component target = (Component) raw[0]; String name = (String) raw[1]; Object data = raw.length < 3 ? null : AuEcho.getData(target, raw[2]); return new Event(name, target, data); }
public void finish() { if (multipartStream == null) return; // finish upload first and get the correct key clean(); int key = ((DesktopCtrl) target.getDesktop().getDelegatee()).getNextKey() - 1; String contentId = Strings.encode(new StringBuffer(12).append("z__ul_"), key).toString(); // copy from AuUploader // perform AU String cmd = "updateResult"; String desktopId = target.getDesktop().getId(); Event event = new Event(cmd, (Component) target.getDelegatee()); Map<String, Object> data = EventDataManager.getInstance().build(event); data.put("wid", target.getUuid()); data.put("contentId", contentId); data.put("sid", "0"); ((ClientCtrl) target.getClient()).postUpdate(desktopId, target.getUuid(), cmd, data, false); ((ClientCtrl) target.getClient()).flush(desktopId); }
public void onPageAttached(Page newpage, Page oldpage) { super.onPageAttached(newpage, oldpage); if (oldpage == null) { //prepare a right moment to init Tree(must be as early as possible) this.addEventListener("onInitModel", _modelInitListener = new ModelInitListener()); Events.postEvent(20000, new Event("onInitModel", this)); //first event to be called } if (_model != null) { postOnInitRender(); if (_dataListener != null) { _model.removeTreeDataListener(_dataListener); _model.addTreeDataListener(_dataListener); } } }
public void finish() { // find upload dialog DesktopAgent desktop = target; ComponentAgent dialog = desktop.query("uploaddlg"); if (dialog == null) throw new AgentException("There is no dialog for uploading."); // perform AU to close dialog String desktopId = desktop.getId(); Event event = new Event(Events.ON_CLOSE, (Component) dialog.getDelegatee()); Map<String, Object> data = EventDataManager.getInstance().build(event); data.put("", true); ((ClientCtrl) getClient()).postUpdate(desktopId, dialog.getUuid(), Events.ON_CLOSE, data, false); ((ClientCtrl) getClient()).flush(desktopId); // reset sid = 0; } }
public void blur() { String desktopId = target.getDesktop().getId(); String cmd = Events.ON_BLUR; Map<String, Object> data = EventDataManager.getInstance().build(new Event(cmd, (Component)target.getDelegatee())); ((ClientCtrl)target.getClient()).postUpdate(desktopId, target.getUuid(), cmd, data, false); ((ClientCtrl)target.getClient()).flush(desktopId); } }
public void group() { String desktopId = target.getDesktop().getId(); String cmd = Events.ON_GROUP; Map<String, Object> data = EventDataManager.getInstance().build(new Event(cmd, (Component)target.getDelegatee())); ((ClientCtrl)target.getClient()).postUpdate(desktopId, target.getUuid(), cmd, data, false); ((ClientCtrl)target.getClient()).flush(desktopId); }
public void focus() { String desktopId = target.getDesktop().getId(); String cmd = Events.ON_FOCUS; Map<String, Object> data = EventDataManager.getInstance().build(new Event(cmd, (Component)target.getDelegatee())); ((ClientCtrl)target.getClient()).postUpdate(desktopId, target.getUuid(), cmd, data, false); ((ClientCtrl)target.getClient()).flush(desktopId); }
public void close() { String desktopId = target.getDesktop().getId(); String cmd = Events.ON_CLOSE; Map<String, Object> data = EventDataManager.getInstance().build(new Event(cmd, (Component)target.getDelegatee())); ((ClientCtrl)target.getClient()).postUpdate(desktopId, target.getUuid(), cmd, data, false); ((ClientCtrl)target.getClient()).flush(desktopId); } }
@Override public void onEvent(Event event) throws Exception { // TODO Auto-generated method stub Component c = event.getTarget(); currentSelectedItem = (WonderbarItem) c.getAttribute(OBJECT_FOR_SELECT); currentSelectedText = (String) c.getAttribute(STRING_FOR_SELECT); Event fevent = new Event("onSelectFromBandbox", TestMenu.this); Executions.getCurrent().postEvent(fevent); }