org.zkoss.zk.ui.Desktop类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(184)

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

Desktop介绍

[英]Represents a desktop. All pages that is created from the same URL is called a desktop.

A desktop is created automatically when the first page is created during a request.

To access a Page, its desktop must be locked first. Once a desktop is locked to a request, all pages contained in this desktop are free to access.
[中]表示桌面。从同一URL创建的所有页面称为桌面。
在请求期间创建第一页时,将自动创建桌面。
要访问页面,必须先锁定其桌面。一旦桌面锁定到请求,此桌面中包含的所有页面都可以自由访问。

代码示例

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

/** Returns whether the desktop is being recovered.
 */
private static final boolean isRecovering(Desktop desktop) {
  final Execution exec = desktop.getExecution();
  return exec != null && ((ExecutionCtrl) exec).isRecovering();
}

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

/** Returns the JavaScript codes to disable (a.k.a., stop) the server push.
 * It is called by {@link #stopClientPush} to prepare the script
 * of {@link AuScript} that will be sent to the client.
 */
protected String getStopScript() {
  final String stop = _desktop.getWebApp().getConfiguration().getPreference("PollingServerPush.stop", null);
  return stop != null ? stop : "zk.cpsp.stop('" + _desktop.getId() + "');";
}

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

public String nextComponentUuid(Desktop desktop, Component comp, ComponentInfo compInfo) {
  String number;
  if ((number = (String) desktop.getAttribute(ID_NUM)) == null) {
    number = "0";
    desktop.setAttribute(ID_NUM, number);
  }
  int i = Integer.parseInt(number);
  i++;
  desktop.setAttribute(ID_NUM, String.valueOf(i));
  return ComponentsCtrl.toAutoId(ID_PREFIX, i);
}

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

public Object setAttribute(String name, Object value, boolean recurse) {
  if (recurse && !hasAttribute(name)) {
    if (_desktop != null) {
      if (_desktop.hasAttribute(name, true))
        return _desktop.setAttribute(name, value, true);
    }
  }
  return setAttribute(name, value);
}

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

out.write(page.getUuid());
out.write("','");
out.write(desktop.getId());
out.write("','");
out.write(getContextURI(exec));
out.write("','");
out.write(desktop.getUpdateURI(null));
out.write("','");
out.write(desktop.getRequestPath());
out.write('\'');
    out.write(">");
    if (page != null) {
      final WebApp wapp = page.getDesktop().getWebApp();
      String currentVersion = wapp.getVersion();
      if (Utils.compareVersion(Utils.parseVersion(currentVersion),

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

public void log(String msg) {
  if (_desktop != null)
    _desktop.getWebApp().log(msg);
  else
    _zklog.info(msg);
}

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

String oldnm = (String) desktop.getAttribute(ATTR_APPNM);
if (oldnm == null)
  oldnm = "ZK";
final String appnm = desktop.getWebApp().getAppName();
if (!oldnm.equals(appnm)) {
  sb.append("zk.appName='");
  Strings.escape(sb, appnm, Strings.ESCAPE_JAVASCRIPT).append("';");
  desktop.setAttribute(ATTR_APPNM, appnm);
sb.append("zk.themeName='");
Strings.escape(sb, themenm, Strings.ESCAPE_JAVASCRIPT).append("';");
desktop.setAttribute(ATTR_THEMENM, themenm);
  WebApp wapp = desktop.getWebApp();
  if (wapp == null || "CE".equals(WebApps.getEdition())
      || wapp.getAttribute("org.zkoss.zk.ui.notice") != null) {

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

/**
 * @param evtnm the event name to echo back
 * @param data the data to sent with the event when echoed back
 * @param dt the desktop to receive the event.
 */
public AuEchoGlobal(String evtnm, String data, Desktop dt) {
  super("echoGx", new String[] { evtnm, data, dt.getId() });
}

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

public void render(Page page, Writer out) throws IOException {
  out.write(HtmlPageRenders.outLangStyleSheets(_exec, null, null));
  out.write(HtmlPageRenders.outLangJavaScripts(_exec, null, null));
  if (_pageDOM) {
    HtmlPageRenders.outPageContent(_exec, page, out, false);
    return;
  }
  final Desktop desktop = _exec.getDesktop();
  out.write("<script class=\"z-runonce\" type=\"text/javascript\">zkpb('");
  out.write(page.getUuid());
  out.write("','");
  out.write(desktop.getId());
  out.write("','");
  out.write(getContextURI());
  out.write("','");
  out.write(desktop.getUpdateURI(null));
  out.write("','");
  out.write(desktop.getRequestPath());
  out.write('\'');
  String style = page.getStyle();
  if (style != null && style.length() > 0) {
    out.write(",{style:'");
    out.write(style);
    out.write("'}");
  }
  out.write(");zkpe();</script>\n");
  for (Component root = page.getFirstRoot(); root != null; root = root.getNextSibling()) {
    HtmlPageRenders.outStandalone(_exec, root, out);
  }
}

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

public Object getAttribute(String name) {
  return desktop.getAttribute(name);
}

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

/**
 * Get the {@link OperationQueue} of {@linkplain OperationThread},
 * It is check is there any {@linkplain OperationThread} exist in desktop.
 * If no, create one ,start it and store in desktop, then return thread's operation queue.
 * If yes, return operation queue directly.  
 * 
 * There is only one {@linkplain OperationThread} in each desktop.
 * @param desktop the associated desktop
 * @return a queue which associate to desktop
 */
public static OperationQueue getQueue(Desktop desktop) {
  if (desktop == null)
    throw new NullPointerException("desktop is null");
  synchronized(desktop) {
    if (!desktop.isAlive()) {
      throw new IllegalStateException("desktop not alive:" + desktop);
    }
    OperationThread t = (OperationThread) desktop.getAttribute(DESKTOP_KEY);
    if (t == null) {
      t = new OperationThread(desktop);
      if(D.ON && log.debugable()){
        log.debug("staring a Operation Thread for desktop:"+desktop+",name="+t.getName());
      }
      desktop.setAttribute(DESKTOP_KEY, t);
      t.start();
      
    }
    return t.getQueue();
  }
}

代码示例来源:origin: org.carewebframework/org.carewebframework.security.spring.core

/**
 * Force transfer of session-based security context to desktop.
 */
@Override
public void onInit(Desktop desktop) {
  HttpSession session = (HttpSession) desktop.getSession().getNativeSession();
  getSecurityContext(session, desktop.getId());
}

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

public void onClose(Event evt) {
  if (evt.getData() == null)
    _result.clear();
  else {
    final Desktop desktop = Executions.getCurrent().getDesktop();
    final Configuration config = desktop.getWebApp().getConfiguration();
    if (!config.isEventThreadEnabled()) {
      if (_listener != null)
        try {
          _listener.onEvent(new UploadEvent(Events.ON_UPLOAD, null, getResult()));
        } catch (Exception e) {
          throw new UiException(e);
        }
      else
        Events.postEvent(new UploadEvent(Events.ON_UPLOAD,
            (Component) desktop.getAttribute(ATTR_FILEUPLOAD_TARGET), getResult()));
    }
  }
  detach();
}

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

/**
   * Creates an instance of {@link UploadEvent} based on the event name and component,
   * the {@link UploadEvent} contains the latest upload media from user.
   * Internal Use Only.
   *
   * @param name event name
   * @param component component that triggers the upload event
   * @return upload event
   * @since 8.6.0
   */
  public static UploadEvent getLatestUploadEvent(String name, Component component) {
    Desktop desktop = component.getDesktop();
    String uuid = component.getUuid();
    final List<Media> result = cast((List) desktop.getAttribute(uuid));
    desktop.removeAttribute(uuid);
    return new UploadEvent(name, desktop.getComponentByUuid(uuid), UploadUtils.parseResult(result));
  }
}

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

throws FileUploadException {
final Map<String, Object> params = new HashMap<String, Object>();
final Configuration conf = desktop.getWebApp().getConfiguration();
int thrs = conf.getFileSizeThreshold();
int sizeThreadHold = 1024 * 128; // maximum size that will be stored in memory
  Integer compMaxsz = (Integer) desktop.getComponentByUuid(request.getParameter("uuid"))
      .getAttribute(Attributes.UPLOAD_MAX_SIZE);
  maxsz = compMaxsz != null ? compMaxsz : conf.getMaxUploadSize();

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

/** Setup this processor before processing the event by calling
 * {@link #process}.
 *
 * <p>Note: it doesn't invoke {@link ExecutionCtrl#onActivate}
 */
public void setup() {
  SessionsCtrl.setCurrent(_desktop.getSession());
  final Execution exec = _desktop.getExecution();
  ExecutionsCtrl.setCurrent(exec);
  ((ExecutionCtrl) exec).setCurrentPage(getPage());
}

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

/** Converts the data of the specified request to a set of Component.
 * The data is assumed to contain a list of item ID in the
 * comman-separated format
 *
 * @return a set of components.
 */
@SuppressWarnings("unchecked")
public static <T extends Component> Set<T> convertToItems(Desktop desktop, List<String> uuids) {
  final Set<T> items = new LinkedHashSet<T>();
  if (uuids != null)
    for (String uuid : uuids) {
      final Component item = desktop.getComponentByUuidIfAny(uuid.trim());
      if (item != null)
        items.add((T) item);
      //notice that it might be null (since the items might be
      //removed by the last request)
    }
  return items;
}

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

public boolean service(AuRequest request, boolean everError) {
  if ("updateResult".equals(request.getCommand())) {
    final Map<String, Object> data = request.getData();
    Desktop desktop = request.getDesktop();
    final String uuid = (String) request.getData().get("wid");
    final Component comp = desktop.getComponentByUuidIfAny(uuid);
    final String sid = (String) request.getData().get("sid");
    if (comp == null) {
      Map<String, Integer> percent = cast((Map) desktop.getAttribute(Attributes.UPLOAD_PERCENT));
      Map<String, Object> size = cast((Map) desktop.getAttribute(Attributes.UPLOAD_SIZE));
      String key = uuid + '_' + sid;
      if (percent != null) {
        percent.remove(key);
        size.put(key, "Upload Aborted");
      }
      return false;
    }
    final List<Media> result = cast((List) AuRequests.getUpdateResult(request));
    Events.postEvent(new UploadEvent(Events.ON_UPLOAD, comp, UploadUtils.parseResult(result)));
    Map percent = (Map) desktop.getAttribute(Attributes.UPLOAD_PERCENT);
    Map size = (Map) desktop.getAttribute(Attributes.UPLOAD_SIZE);
    final String key = uuid + '_' + sid;
    percent.remove(key);
    size.remove(key);
    return true;
  }
  return false;
}

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

/** Process fileitems named file0, file1 and so on.
 */
private static final void processItems(Desktop desktop, Map<String, Object> params, Map<String, String> attrs)
    throws IOException {
  final List<Media> meds = new LinkedList<Media>();
  final boolean alwaysNative = "true".equals(params.get("native"));
  final Object fis = params.get("file");
  if (fis instanceof FileItem) {
    meds.add(processItem(desktop, (FileItem) fis, alwaysNative,
        (org.zkoss.zk.ui.sys.DiskFileItemFactory) params.get("diskFileItemFactory")));
  } else if (fis != null) {
    for (Iterator it = ((List) fis).iterator(); it.hasNext();) {
      meds.add(processItem(desktop, (FileItem) it.next(), alwaysNative,
          (org.zkoss.zk.ui.sys.DiskFileItemFactory) params.get("diskFileItemFactory")));
    }
  }
  final String contentId = Strings
      .encode(new StringBuffer(12).append("z__ul_"), ((DesktopCtrl) desktop).getNextKey()).toString();
  attrs.put("contentId", contentId);
  desktop.setAttribute(contentId, meds);
}

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

/** Activates this request.
 * <p>Used internally to identify the component and page after
 * an execution is activated. Applications rarely need to access this
 * method.
 * @since 3.0.5
 */
public void activate() throws ComponentNotFoundException {
  if (_uuid != null) {
    _comp = _desktop.getComponentByUuidIfAny(_uuid);
    if (_comp != null) {
      _page = _comp.getPage();
    } else {
      _page = _desktop.getPageIfAny(_uuid); //it could be page UUID
      if (_page == null)
        throw new ComponentNotFoundException("Component not found: " + _uuid);
    }
  }
}

相关文章