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

📄 pagedefinition.java

📁 ZK 基础介绍 功能操作 模块 结合数据库操作
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			_headerdefs = new LinkedList();		_headerdefs.add(header);	}	/** Converts the header definitions (added by {@link #addHeaderInfo}) to	 * HTML tags.	 */	public String getHeaders(Page page) {		if (_headerdefs == null)			return "";		final StringBuffer sb = new StringBuffer(256);		for (Iterator it = _headerdefs.iterator(); it.hasNext();)			sb.append(((HeaderInfo)it.next()).toHTML(this, page)).append('\n');		return sb.toString();	}	/** Returns the content type (after evaluation),	 * or null to use the device default.	 *	 * @param page the page used to evaluate EL expressions, if any	 * @since 3.0.0	 */	public String getContentType(Page page) {		return _contentType != null ?			(String)_contentType.getValue(_evalr, page): null;	}	/** Sets the content type.	 *	 * <p>Default: null (use the device default).	 *	 * @param contentType the content type. It may coontain EL expressions.	 * @since 3.0.0	 */	public void setContentType(String contentType) {		_contentType = contentType != null && contentType.length() > 0 ?			new ExValue(contentType, String.class): null;	}	/** Returns the doc type (&lt;!DOCTYPE&gt;) (after evaluation),	 * or null to use the device default.	 *	 * @param page the page used to evaluate EL expressions, if any	 * @since 3.0.0	 */	public String getDocType(Page page) {		return _docType != null ?			(String)_docType.getValue(_evalr, page): null;	}	/** Sets the doc type (&lt;!DOCTYPE&gt;).	 *	 * <p>Default: null (use the device default).	 *	 * @param docType the doc type. It may coontain EL expressions.	 * @since 3.0.0	 */	public void setDocType(String docType) {		_docType = docType != null && docType.length() > 0 ?			new ExValue(docType, String.class): null;	}	/** Returns the first line to be generated to the output	 * (after evaluation), or null if nothing to generate.	 *	 * <p>For XML devices, it is usually the xml processing instruction:<br/>	 * <code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;	 *	 * @param page the page used to evaluate EL expressions, if any	 * @since 3.0.0	 */	public String getFirstLine(Page page) {		return _firstLine != null ?			(String)_firstLine.getValue(_evalr, page): null;	}	/** Sets the first line to be generated to the output.	 *	 * <p>Default: null (i.e., nothing generated)	 * @since 3.0.0	 */	public void setFirstLine(String firstLine) {		_firstLine = firstLine != null && firstLine.length() > 0 ?			new ExValue(firstLine, String.class): null;	}	/** Returns if the client can cache the rendered result, or null	 * to use the device default.	 *	 * @since 3.0.0	 */	public Boolean getCacheable() {		return _cacheable;	}	/** Sets if the client can cache the rendered result.	 *	 * <p>Default: null (use the device default).	 * @since 3.0.0	 */	public void setCacheable(Boolean cacheable) {		_cacheable = cacheable;	}	/** Adds a root attribute.	 * The previous attributee of the same will be replaced.	 *	 * @param value the value. If null, the attribute is removed.	 * It can be an EL expression.	 * @since 3.0.0	 */	public void setRootAttribute(String name, String value) {		if (name == null || name.length() == 0)			throw new IllegalArgumentException();		if (_rootAttrs == null) {			if (value == null)				return; //nothing to			_rootAttrs = new LinkedHashMap();		}		if (value == null) _rootAttrs.remove(name);		else _rootAttrs.put(name, new ExValue(value, String.class));	}	/** Converts the header definitions (added by {@link #setRootAttribute})	 * to the attributes of the root element.	 * For HTML, the root element is the HTML element.	 * @since 3.0.0	 */	public String getRootAttributes(Page page) {		if (_rootAttrs == null || _rootAttrs.isEmpty())			return "";		final Evaluator eval = getEvaluator();		final StringBuffer sb = new StringBuffer(256);		for (Iterator it = _rootAttrs.entrySet().iterator(); it.hasNext();) {			final Map.Entry me = (Map.Entry)it.next();			final String val = (String)				((ExValue)me.getValue()).getValue(eval, page);			if (val != null)				HTMLs.appendAttribute(sb, (String)me.getKey(), val);		}		return sb.toString();	}	/** Returns the map of component definition (never null).	 */	public ComponentDefinitionMap getComponentDefinitionMap() {		return _compdefs;	}	/** Adds a component definition belonging to this page definition only.	 *	 * <p>It is the same as calling {@link ComponentDefinitionMap#add} 	 * against {@link #getComponentDefinitionMap}	 */	public void addComponentDefinition(ComponentDefinition compdef) {		final LanguageDefinition langdef = compdef.getLanguageDefinition();		if (langdef != null) {			final LanguageDefinition ld2 = getLanguageDefinition();			if (langdef != ld2			&& !langdef.getDeviceType().equals(ld2.getDeviceType()))				throw new UiException("Component definition, "+compdef					+", does not belong to the same device type of the page definition, "					+ld2.getDeviceType());		}		_compdefs.add(compdef);	}	/** Returns the component definition of the specified name, or null	 * if not found.	 *	 * <p>Note: unlike {@link LanguageDefinition#getComponentDefinition},	 * this method doesn't throw ComponentNotFoundException if not found.	 * It just returns null.	 *	 * @param recur whether to look up the component from {@link #getLanguageDefinition}	 */	public ComponentDefinition getComponentDefinition(String name, boolean recur) {		final ComponentDefinition compdef = _compdefs.get(name);		if (!recur || compdef != null)			return compdef;		try {			return getLanguageDefinition().getComponentDefinition(name);		} catch (DefinitionNotFoundException ex) {		}		return null;	}	/** Returns the component definition of the specified class, or null	 * if not found.	 *	 * <p>Note: unlike {@link LanguageDefinition#getComponentDefinition},	 * this method doesn't throw ComponentNotFoundException if not found.	 * It just returns null.	 *	 * @param recur whether to look up the component from {@link #getLanguageDefinition}	 */	public ComponentDefinition getComponentDefinition(Class cls, boolean recur) {		final ComponentDefinition compdef = _compdefs.get(cls);		if (!recur || compdef != null)			return compdef;		try {			return getLanguageDefinition().getComponentDefinition(cls);		} catch (DefinitionNotFoundException ex) {		}		return null;	}	/** Adds a tag lib. */	public void addTaglib(Taglib taglib) {		if (taglib == null)			throw new IllegalArgumentException("null");		if (_taglibs == null)			_taglibs = new LinkedList();		_taglibs.add(taglib);		_eval = null; //ask for re-gen		_mapper = null; //ask for re-parse	}	/** Adds an imported class to the expression factory.	 * @since 3.0.0	 */	public void addExpressionImport(String nm, Class cls) {		if (nm == null || cls == null)			throw new IllegalArgumentException();		if (_expimps == null)			_expimps = new HashMap(4);		_expimps.put(nm, cls);		_eval = null; //ask for re-gen		_mapper = null; //ask for re-parse	}	/** Sets the implementation of the expression factory that shall	 * be used by this page.	 *	 * <p>Default: null (use the default).	 *	 * @param expfcls the implemtation class, or null to use the default.	 * Note: expfcls must implement {@link ExpressionFactory}.	 * If null is specified, the class defined in	 * {@link org.zkoss.zk.ui.util.Configuration#getExpressionFactoryClass}	 * @since 3.0.0	 */	public void setExpressionFactoryClass(Class expfcls) {		if (expfcls != null && !ExpressionFactory.class.isAssignableFrom(expfcls))			throw new IllegalArgumentException(expfcls+" must implement "+ExpressionFactory.class);		_expfcls = expfcls;	}	/** Returns the implementation of the expression factory that	 * is used by this page, or null if	 * {@link org.zkoss.zk.ui.util.Configuration#getExpressionFactoryClass}	 * is used.	 *	 * @see #setExpressionFactoryClass	 * @since 3.0.0	 */	public Class getExpressionFactoryClass() {		return _expfcls;	}	/** Returns the evaluator based on this page definition (never null).	 * @since 3.0.0	 */	public Evaluator getEvaluator() {		if (_eval == null)			_eval = newEvaluator();		return _eval;	}	private Evaluator newEvaluator() {		return new SimpleEvaluator(getFunctionMapper(), _expfcls);	}	/** Returns the evaluator reference (never null).	 *	 * @since 3.0.0	 */	public EvaluatorRef getEvaluatorRef() {		if (_evalr == null)			_evalr = newEvaluatorRef();		return _evalr;	}	private EvaluatorRef newEvaluatorRef() {		return new PageEvalRef(this);	}	/** Returns the function mapper, or null if no mappter at all.	 */	public FunctionMapper getFunctionMapper() {		if (_mapper == null) {			_mapper = Taglibs.getFunctionMapper(_taglibs, _expimps, _xelmtds, _locator);			if (_mapper == null)				_mapper = Expressions.EMPTY_MAPPER;		}		return _mapper != Expressions.EMPTY_MAPPER ? _mapper: null;	}	/** Initializes a page after execution is activated.	 * It setup the identifier and title, and adds it to desktop.	 */	public void init(final Page page, final boolean evalHeaders) {		((PageCtrl)page).init(			new PageConfig() {				public String getId() {return _id;}				public String getUuid() {return null;}				public String getTitle() {return _title;}				public String getStyle() {return _style;}				public String getHeaders() {					return evalHeaders ?						PageDefinition.this.getHeaders(page): "";				}				public String getRootAttributes() {					return PageDefinition.this.getRootAttributes(page);				}				public String getContentType() {					return PageDefinition.this.getContentType(page);				}				public String getDocType() {					return PageDefinition.this.getDocType(page);				}				public String getFirstLine() {					return PageDefinition.this.getFirstLine(page);				}				public Boolean getCacheable() {return _cacheable;}			});	}	//NodeInfo//	public PageDefinition getPageDefinition() {		return this;	}	//Object//	public String toString() {		return "[PageDefinition:"+(_id != null ? _id: _title)+']';	}}

⌨️ 快捷键说明

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