org.zkoss.zk.ui.event.Events.isListened()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(192)

本文整理了Java中org.zkoss.zk.ui.event.Events.isListened()方法的一些代码示例,展示了Events.isListened()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Events.isListened()方法的具体详情如下:
包路径:org.zkoss.zk.ui.event.Events
类名称:Events
方法名:isListened

Events.isListened介绍

[英]Returns whether an event handler or listener is available for the specified component and event.

A event handler is either a public method named onXxx or a ZUL attribute named onXxx, where onXxx is the event name. A event listener is EventListener being added by Component#addEventListener and Page#addEventListener.

Unlike Component#isListenerAvailable, which checks only the event listener, this method check both event handlers and listeners, i.e., the onXxx members defined in ZUML, the onXxx method defined in the implementation class, and the event listener registered.
[中]返回指定组件和事件的事件处理程序或侦听器是否可用。
事件处理程序是名为onXxx的公共方法或名为onXxx的ZUL属性,其中onXxx是事件名称。事件侦听器是由组件#addEventListener和页面#addEventListener添加的事件侦听器。
与只检查事件侦听器的组件#IsListenerable不同,此方法同时检查事件处理程序和侦听器,即ZUML中定义的onXxx成员、实现类中定义的onXxx方法和注册的事件侦听器。

代码示例

代码示例来源:origin: org.zkoss.zk/zul

public boolean isDeferrable() {
    return !Events.isListened(Tabbox.this, Events.ON_SELECT, true);
  }
}

代码示例来源:origin: org.zkoss.zk/zkplus

/*package*/ static void postOnCreateEvents(Component item) {
    for (final Iterator it = item.getChildren().iterator(); it.hasNext();) {
      final Component child = (Component) it.next();
      postOnCreateEvents(child); //recursive
    }
    if (Events.isListened(item, Events.ON_CREATE, false)) {
      Events.postEvent(new CreateEvent(Events.ON_CREATE, item, null));
    }
  }
}

代码示例来源:origin: org.zkoss.zk/zk

public boolean removeEventListener(String evtnm, EventListener<? extends Event> listener) {
  if (evtnm == null || listener == null)
    throw new IllegalArgumentException("null");
  if (_auxinf != null && _auxinf.listeners != null) {
    final boolean oldasap = Events.isListened(this, evtnm, true);
    final List<EventListenerInfo> lis = _auxinf.listeners.get(evtnm);
    if (lis != null) {
      for (Iterator<EventListenerInfo> it = lis.iterator(); it.hasNext();) {
        final EventListenerInfo li = it.next();
        if (li.listener.equals(listener)) {
          it.remove();
          if (lis.isEmpty())
            _auxinf.listeners.remove(evtnm);
          final Desktop desktop = getDesktop();
          if (desktop != null) {
            onListenerChange(desktop, false);
            if (getClientEvents().containsKey(evtnm)) {
              if (lis.isEmpty() && !Events.isListened(this, evtnm, false))
                smartUpdate("$" + evtnm, (Object) null); //no listener at all
              else if (oldasap != Events.isListened(this, evtnm, true))
                smartUpdate("$" + evtnm, !oldasap);
            }
          }
          return true;
        }
      }
    }
  }
  return false;
}

代码示例来源:origin: org.zkoss.zk/zk

private void onListenerChange(Desktop desktop, boolean listen) {
  if (listen) {
    if (Events.isListened(this, Events.ON_CLIENT_INFO, false)) { //asap+deferrable
      response(new AuClientInfo(desktop));
      getDesktop().setAttribute("org.zkoss.desktop.clientinfo.enabled", true);
      //We always fire event not a root, since we don't like to
      //check when setParent or setPage is called
    }
    if (Events.isListened(this, Events.ON_PIGGYBACK, false))
      ((DesktopCtrl) desktop).onPiggybackListened(this, true);
    if (Events.isListened(this, Events.ON_VISIBILITY_CHANGE, false))
      getDesktop().setAttribute("org.zkoss.desktop.visibilitychange.enabled", true);
  } else {
    if (!Events.isListened(this, Events.ON_PIGGYBACK, false))
      ((DesktopCtrl) desktop).onPiggybackListened(this, false);
  }
}

代码示例来源:origin: org.zkoss.zk/zhtml

final int flags = ((Integer) me.getValue()).intValue();
if ((flags & ComponentCtrl.CE_IMPORTANT) != 0
    || Events.isListened(comp, evtnm, false)) {
  if (first)
    first = false;
    _jsout.append(',');
  _jsout.append('$').append(evtnm).append(':')
      .append(Events.isListened(comp, evtnm, true));

代码示例来源:origin: org.zkoss.zats/zats-mimic

/**
 * lookup the event target of a component, it look up the component and its
 * ancient. use this for search the actual target what will receive a event
 * for a action on a component-agent
 * <p/>
 * Currently, i get it by server side directly
 */
public static ComponentAgent lookupEventTarget(ComponentAgent c, String evtname) {
  if (c == null)
    return null;
  Component comp = (Component)c.getDelegatee();
  if (Events.isListened(comp, evtname, true)) {
    return c;
  }
  return lookupEventTarget(c.getParent(), evtname);
}

代码示例来源:origin: org.zkoss.zk/zk

throw new IllegalArgumentException("Invalid event name: " + evtnm);
final boolean oldasap = Events.isListened(this, evtnm, true);
    desktop.setAttribute("org.zkoss.desktop.visibilitychange.enabled", true);
  } else if (getClientEvents().containsKey(evtnm)) {
    final boolean asap = Events.isListened(this, evtnm, true);
    if (lis.size() == 1 || oldasap != asap)
      smartUpdate("$" + evtnm, asap);

代码示例来源:origin: org.zkoss.zk/zuljsp

if (Events.isListened(_comp, Events.ON_CREATE, false))//send onCreate event...
  Events.postEvent(
    new CreateEvent(Events.ON_CREATE, _comp, Executions.getCurrent().getArg()));

代码示例来源:origin: org.zkoss.zk/zk

public void afterProcessEvent(Event event) throws Exception {
  _eis.afterProcessEvent(event);
  _wapp.getConfiguration().afterProcessEvent(event);
  if (Events.ON_DESKTOP_RECYCLE.equals(event.getName())) {
    if (_bookmark.length() > 0)
      addResponse(new AuBookmark(_bookmark));
    l_out: for (Page page : _pages)
      for (Component root = page.getFirstRoot(); root != null; root = root.getNextSibling())
        if (Events.isListened(root, Events.ON_CLIENT_INFO, false)) {
          setAttribute("org.zkoss.desktop.clientinfo.enabled", true);
          addResponse(new AuClientInfo(this));
          break l_out;
        }
    l_out: for (Page page : _pages)
      for (Component root = page.getFirstRoot(); root != null; root = root.getNextSibling())
        if (Events.isListened(root, Events.ON_VISIBILITY_CHANGE, false)) {
          setAttribute("org.zkoss.desktop.visibilitychange.enabled", true);
          break l_out;
        }
  }
}

代码示例来源:origin: org.zkoss.zk/zk

isImportant = true;
if (Events.isListened(this, evtnm, false)) {
  renderer.render('$' + evtnm, Events.isListened(this, evtnm, true));

代码示例来源:origin: org.zkoss.zk/zk

public void onPiggyback() {
  //Note: we don't post ON_PIGGYBACK twice in an execution
  //(performance concern and back-compatibility).
  if (_piggybackListened && Executions.getCurrent().getAttribute(ATTR_PIGGYBACK_POSTED) == null) {
    for (Page page : _pages) {
      if (Executions.getCurrent().isAsyncUpdate(page)) { //ignore new created pages
        for (Component root = page.getFirstRoot(); root != null; root = root.getNextSibling()) {
          if (Events.isListened(root, Events.ON_PIGGYBACK, false)) { //asap+deferrable
            Events.postEvent(new Event(Events.ON_PIGGYBACK, root));
            Executions.getCurrent().setAttribute(ATTR_PIGGYBACK_POSTED, Boolean.TRUE);
          }
        }
      }
    }
  }
  if (!_schedInfos.isEmpty())
    Events.postEvent(ON_SCHEDULE, _dummyTarget, null);
  //we could not process them here (otherwise, event handling, thread
  //might not work)
  //Thus, we post an event and handle it in _dummyTarget
  if (_spush != null)
    _spush.onPiggyback();
}

代码示例来源:origin: org.zkoss.zk/zkex

if (Events.isListened(chart, Events.ON_CLICK, false) || chart.isShowTooltiptext()) {
  int j = 0;
  String preUrl = null;

相关文章