facesgisresourcefactory.java

来自「esri的ArcGIS Server超级学习模板程序(for java)」· Java 代码 · 共 55 行

JAVA
55
字号
package com.esri.solutions.jitk.web.data;

import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;

import com.esri.adf.web.data.GISResource;

/**
 * Implementation of {@link IGISResourceFactory} that uses 
 * Faces to create a GIS Resource.  The {@link #createResource()}
 * method essentially creates a new instance of a managed bean
 * that is specified through the {@link #setManagedBeanName(String)}
 * method.
 */
public class FacesGISResourceFactory implements IGISResourceFactory<GISResource> {

	/**
	 * Name of Managed Bean to create a new instance from.
	 */
	private String m_name;

	/*
	 * (non-Javadoc)
	 * @see com.esri.solutions.jitk.web.data.IGISResourceFactory#createResource()
	 */
	public GISResource createResource() {
		
		FacesContext fc = FacesContext.getCurrentInstance();
		String vbString = "#{" + m_name + "}";
		
		ValueBinding vb = fc.getApplication().createValueBinding(vbString);
		return (GISResource) vb.getValue(fc);
	}

	/**
	 * Calls {@link #createResource()}.  Helper method for integrating
	 * into bean frameworks such as Faces.
	 * 
	 * @return	New Instance of Managed Bean
	 */
	public GISResource getResource () {
		return createResource();
	}
	
	/**
	 * Sets the name of the managed bean that should be
	 * instantiated from {@link #createResource()}.
	 * 
	 * @param name	Name of Managed Bean.
	 */
	public void setManagedBeanName (String name) {
		m_name = name;
	}
}

⌨️ 快捷键说明

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