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

📄 errorrenderer.java

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JAVA
字号:
package com.esri.solutions.jitk.web.error;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;

import org.w3c.dom.Element;

import com.esri.adf.web.faces.component.TaskControl;
import com.esri.adf.web.faces.renderkit.xml.ajax.AJAXRenderer;

/**
 * Renders the Errors in the Error Sink to the Response.  An instance of
 * {@link XmlErrorSinkExporter} is required in order to export the Errors in
 * the Errors Sink to an XML Document.  The XML Document is appended to the 
 * XML Response Document.  The browser will be responsible for parsing the
 * Errors XML Element and rendering a UI.  This renderer will not transform the
 * Errors XML Element into a UI.
 */
public class ErrorRenderer implements AJAXRenderer {

	/**
	 * Reference to the Error Sink, contains the Errors received from components.
	 */
	private IErrorSink m_sink;
	
	/**
	 * Reference to exporter that exports Error Sink to an XML Document.
	 */
	private XmlErrorSinkExporter m_exporter;

	/*
	 * (non-Javadoc)
	 * @see com.esri.adf.web.faces.renderkit.xml.ajax.AJAXRenderer#getControlClass()
	 */
	@SuppressWarnings("unchecked")
	public Class getControlClass() {
		return TaskControl.class;
	}

	/*
	 * (non-Javadoc)
	 * @see com.esri.adf.web.faces.renderkit.xml.ajax.AJAXRenderer#getOriginalState(javax.faces.component.UIComponent)
	 */
	public Object getOriginalState(UIComponent component) {
		if (m_sink != null) {
			return Integer.valueOf(m_sink.count());
		}
		return Integer.valueOf(0);
	}

	/*
	 * (non-Javadoc)
	 * @see com.esri.adf.web.faces.renderkit.xml.ajax.AJAXRenderer#renderAjaxResponse(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object, boolean, org.w3c.dom.Element)
	 */
	public void renderAjaxResponse(FacesContext fc, 
								   UIComponent ctrl,
								   Object state, 
								   boolean isEventSource, 
								   Element parent) {
	
		if (m_sink != null && m_sink.count() > 0 && m_exporter != null) {
			m_exporter.setParent(parent);
			m_sink.export(m_exporter);
			m_sink.clear();
		}
	}
	
	/**
	 * Sets the reference to the Error Sink that contains the Errors that were received from
	 * components.
	 * 
	 * @param sink	Error Sink.
	 */
	public void setErrorSink (IErrorSink sink) {
		m_sink = sink;
	}

	/**
	 * Sets the reference to the exporter that will be used to export the Errors Sink to
	 * an XML Document.  This instance will be used multiple times.
	 * 
	 * @param exporter  Exports Error Sink to XML Document.
	 */
	public void setXmlErrorSinkExporter (XmlErrorSinkExporter exporter) {
		m_exporter = exporter;
	}
}

⌨️ 快捷键说明

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