📄 executions.java
字号:
/* Executions.java{{IS_NOTE Purpose: Description: History: Fri Jun 3 17:55:08 2005, Created by tomyeh}}IS_NOTECopyright (C) 2005 Potix Corporation. All Rights Reserved.{{IS_RIGHT This program is distributed under GPL Version 2.0 in the hope that it will be useful, but WITHOUT ANY WARRANTY.}}IS_RIGHT*/package org.zkoss.zk.ui;import java.util.Map;import java.io.Reader;import java.io.Writer;import java.io.IOException;import org.zkoss.idom.Document;import org.zkoss.zk.ui.metainfo.PageDefinition;import org.zkoss.zk.ui.metainfo.LanguageDefinition;import org.zkoss.zk.ui.sys.UiEngine;import org.zkoss.zk.ui.sys.WebAppCtrl;/** * Utilities to access {@link Execution}. * * @author tomyeh */public class Executions { /** Stores the current {@link Execution}. */ protected static final ThreadLocal _exec = new ThreadLocal(); /** Returns the current execution. */ public static final Execution getCurrent() { return (Execution)_exec.get(); } /** Evluates the specified expression by use of the current context * ({@link #getCurrent}). * * <p>The function mapper is retrieved from component's page's function * mapper ({@link Page#getFunctionMapper}). * If null, the current page, if any, is used to retrieve * the mapper. * * @param comp as the self variable (ignored if null) */ public static final Object evaluate(Component comp, String expr, Class expectedType) { return getCurrent().evaluate(comp, expr, expectedType); } /** Evluates the specified expression with the resolver of the current * execution ({@link #getCurrent}). * * <p>The function mapper is retrieved from page's function * mapper ({@link Page#getFunctionMapper}). * If null, the current page, if any, is used to retrieve * the mapper. * * @param page used as the self variable and to retrieve the function * mapper if funmap is not defined. Ignored if null. */ public static final Object evaluate(Page page, String expr, Class expectedType) { return getCurrent().evaluate(page, expr, expectedType); } /** Encodes an URL. * * <p>It resolves "*" contained in URI, if any, to the proper Locale, * and the browser code. * Refer to {@link org.zkoss.web.servlet.Servlets#locate(ServletContext, ServletRequest, String, Locator)} * for details. */ public static final String encodeURL(String uri) { return getCurrent().encodeURL(uri); } /** Creates components from a page file specified by an URI. * Shortcut to {@link Execution#createComponents(String, Component, Map)}. * * @param parent the parent component, or null if you want it to be * a root component. If parent is null, the page is assumed to be * the current page, which is determined by the execution context. * @param arg a map of parameters that is accessible by the arg variable * in EL, or by {@link Execution#getArg}. * Ignored if null. * @see #createComponents(PageDefinition, Component, Map) */ public static final Component createComponents( String uri, Component parent, Map arg) { return getCurrent().createComponents(uri, parent, arg); } /** Creates components based on the specified page definition. * Shortcut to {@link Execution#createComponents(PageDefinition, Component, Map)}. * * @param pagedef the page definition to use. It cannot be null. * @param parent the parent component, or null if you want it to be * a root component. If parent is null, the page is assumed to be * the current page, which is determined by the execution context. * @param arg a map of parameters that is accessible by the arg variable * in EL, or by {@link Execution#getArg}. * Ignored if null. * @return the first component being created. * @see #createComponents(String, Component, Map) */ public static final Component createComponents(PageDefinition pagedef, Component parent, Map arg) { return getCurrent().createComponents(pagedef, parent, arg); } /** Creates components from the raw content specified by a string. * Shortcut to {@link Execution#createComponentsDirectly(String, String, Component, Map)}. * * @param content the raw content of the page. It must be a XML and * compliant to the page format (such as ZUL). * @param extension the default extension if the content doesn't specify * an language. In other words, if * the content doesn't specify an language, {@link LanguageDefinition#getByExtension} * is called. * If extension is null and the content doesn't specify a language, * the language called "xul/html" is assumed. * @param parent the parent component, or null if you want it to be * a root component. If parent is null, the page is assumed to be * the current page, which is determined by the execution context. * @param arg a map of parameters that is accessible by the arg variable * in EL, or by {@link Execution#getArg}. * Ignored if null. * @see #createComponents(PageDefinition, Component, Map) * @see #createComponents(String, Component, Map) * @see #createComponentsDirectly(Document, String, Component, Map) * @see #createComponentsDirectly(Reader, String, Component, Map) */ public static final Component createComponentsDirectly(String content, String extension, Component parent, Map arg) { return getCurrent().createComponentsDirectly(content, extension, parent, arg); } /** Creates components from the raw content specified by a DOM tree. * Shortcut to {@link Execution#createComponentsDirectly(Document, String, Component, Map)}. * * @param content the raw content in DOM. * @param extension the default extension if the content doesn't specify * an language. In other words, if * the content doesn't specify an language, {@link LanguageDefinition#getByExtension} * is called. * If extension is null and the content doesn't specify a language, * the language called "xul/html" is assumed. * @param parent the parent component, or null if you want it to be * a root component. If parent is null, the page is assumed to be * the current page, which is determined by the execution context. * @param arg a map of parameters that is accessible by the arg variable * in EL, or by {@link Execution#getArg}. * Ignored if null. * @see #createComponents(PageDefinition, Component, Map) * @see #createComponents(String, Component, Map) * @see #createComponentsDirectly(String, String, Component, Map) * @see #createComponentsDirectly(Reader, String, Component, Map) */ public static final Component createComponentsDirectly(Document content, String extension, Component parent, Map arg) { return getCurrent().createComponentsDirectly(content, extension, parent, arg); } /** Creates components from the raw content read from the specified reader. * Shortcut to {@link Execution#createComponentsDirectly(Reader, String, Component, Map)}. * * <p>The raw content is loader and parsed to a page defintion by use of * {@link Execution#getPageDefinitionDirectly(Reader, String)}, and then * invokes {@link #createComponents(PageDefinition,Component,Map)} * to create components. * * @param reader the reader to retrieve the raw content. * @param extension the default extension if the content doesn't specify * an language. In other words, if * the content doesn't specify an language, {@link LanguageDefinition#getByExtension} * is called. * If extension is null and the content doesn't specify a language, * the language called "xul/html" is assumed. * @param parent the parent component, or null if you want it to be * a root component. If parent is null, the page is assumed to be * the current page, which is determined by the execution context. * @param arg a map of parameters that is accessible by the arg variable * in EL, or by {@link Execution#getArg}. * Ignored if null. * @see #createComponents(PageDefinition, Component, Map) * @see #createComponents(String, Component, Map) * @see #createComponentsDirectly(Document, String, Component, Map) * @see #createComponentsDirectly(String, String, Component, Map) */ public static Component createComponentsDirectly(Reader reader, String extension, Component parent, Map arg) throws IOException { return getCurrent().createComponentsDirectly(reader, extension, parent, arg); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -