⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 executions.java

📁 ZK 基础介绍 功能操作 模块 结合数据库操作
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* 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.xel.Evaluator;import org.zkoss.zk.ui.sys.UiEngine;import org.zkoss.zk.ui.sys.WebAppCtrl;import org.zkoss.zk.ui.sys.DesktopCtrl;import org.zkoss.zk.ui.sys.ServerPush;/** * 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();	}	/** Returns the evaluator of the current execution.	 * It is usually used to parse the expression into {@link org.zkoss.xel.Expression}	 * or used with {@link org.zkoss.zk.xel.ExValue}.	 * for performance improvement.	 *	 * @param page the page that this evaluator is associated.	 * If null, the current page and then the first page is assumed.	 * @param expfcls the implementation of {@link org.zkoss.xel.ExpressionFactory},	 * or null to use the default ({@link org.zkoss.zk.ui.util.Configuration#getExpressionFactoryClass}.	 * @since 3.0.0	 */	public static final Evaluator getEvaluator(Page page, Class expfcls) {		return getCurrent().getEvaluator(page, expfcls);	}	/** Returns the evaluator of the current execution.	 * It is a shortcut of getEvaluator(comp != null ? comp.getPage(): null)	 *	 * @param comp the component to retrieve the page for the evaluator	 * @param expfcls the implementation of {@link org.zkoss.xel.ExpressionFactory},	 * or null to use the default ({@link org.zkoss.zk.ui.util.Configuration#getExpressionFactoryClass}.	 * @since 3.0.0	 */	public static final Evaluator getEvaluator(Component comp, Class expfcls) {		return getCurrent().getEvaluator(comp, expfcls);	}	/** 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.	 *	 * <p>For better performance, you can use the instance returned by	 *{@link #getEvaluator} to parse and cached the parsed expression.	 * {@link org.zkoss.zk.xel.ExValue} is a utility class to simply	 * the task.	 *	 * @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.	 *	 * <p>For better performance, you can use the instance returned by	 *{@link #getEvaluator} to parse and cached the parsed expression.	 * {@link org.zkoss.zk.xel.ExValue} is a utility class to simply	 * the task.	 *	 * @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);	}	/** Sends a temporary redirect response to the client using the specified	 * redirect location URL by use of the current execution,	 * {@link #getCurrent}.	 *	 * <p>After calling this method, the caller shall end the processing	 * immediately (by returning). All pending requests and events will	 * be dropped.	 *	 * @param uri the URI to redirect to, or null to reload the same page	 * @see Execution#sendRedirect	 */	public static void sendRedirect(String uri) {		getCurrent().sendRedirect(uri);	}	/** A shortcut of Executions.getCurrent().include(page).	 *	 * @see Execution#include(Writer,String,Map,int)	 * @see Execution#include(String)	 */	public static void include(String page)	throws IOException {		getCurrent().include(page);	}	/** A shortcut of Executions.getCurrent().forward(page).	 *	 * @see Execution#forward(Writer,String,Map,int)	 * @see Execution#forward(String)	 */	public static void forward(String page)	throws IOException {		getCurrent().forward(page);	}	//-- wait/notify --//	/** Suspends the current processing of an event and wait until the	 * other thread invokes {@link #notify(Object)}, {@link #notifyAll(Object)},	 * {@link #notify(Desktop, Object)} or {@link #notifyAll(Desktop, Object)}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -