com.esri.adf.web.util
Class WebUtil

java.lang.Object
  extended by com.esri.adf.web.util.WebUtil

public class WebUtil
extends Object

Utility methods to retrieve information about the controls.


Field Summary
static String COMPONENT_FAMILY_PREFIX
          The prefix for name of the family of GIS server web controls.
static String COMPONENT_TYPE_PREFIX
          The prefix for name of the component type for GIS server web controls.
static String VALIDATOR_PREFIX
          The prefix for name of the validators for GIS server web controls.
 
Constructor Summary
WebUtil()
           
 
Method Summary
static
<T extends Serializable>
T
copy(T src)
          Deprecated. As of ArcGIS Server 10.0, instead use ADFUtil.copy(Serializable)
static ContextControl findParentContextControl(javax.faces.component.UIComponent component)
          Finds the most immediate ContextControl parent for this component.
static List<javax.faces.component.UIComponent> getAllChildren(javax.faces.component.UIComponent comp)
          The method will retrieve all children components under given component.
static Map<String,TaskControl> getAllTaskControls(javax.faces.component.UIComponent component)
          Returns all Task controls in a map with id and object pair under the given component.
static String getClient(javax.faces.context.FacesContext facesContext)
          Extracts the user-agent header from the HTTP Servlet request.
static javax.faces.component.UIComponent getComponentById(String id)
          Returns the UIComponent object matching the given id; The method will search all UIComponent objects under the root view of current context; Null will be returned if no UIComponent object with the given id is found;
static javax.faces.component.UIComponent getComponentById(javax.faces.component.UIComponent comp, String id)
          Returns the UIComponent object matching the given id; The method will only search the children components under the given UIComponent; Null will be returned if no UIComponent object with the id is found;
static javax.faces.context.ExternalContext getExternalContext()
           
static javax.faces.context.FacesContext getFacesContext()
           
static String getMimeId(Object obj)
          Return the unique identifier used for MIME data.
static String getMimeURL(String id, byte[] mimeData, WebSession webSession)
          Returns the URL for MIME data.
static String getMimeURL(String id, WebSession webSession)
           
static String getRequestContextPath()
           
static URL getResource(String name)
          Finds the resource with the given name.
static String getTileURL(String id, Object value, WebSession webSession, String tileImageFormat)
          Returns the URL for Tile data.
static String getTileURL(String id, String value, WebSession webSession)
          Returns the URL for Tile data.
static WebContext getWebContext(javax.faces.context.FacesContext facesContext, String contextId)
          Finds the WebContext in the request map of this FacesContext.
static WebContext getWebContext(javax.faces.component.UIComponent component)
          Finds the parent ContextControl for this component and returns the associated WebContext.
static WebContext getWebContext(javax.faces.component.UIComponent component, String contextId)
          If contextId is not null, return the WebContext associated with that ID.
static boolean isCommonResourcesRegistered(javax.faces.context.FacesContext facesContext)
          Indicates if the common resources have been registered in this request.
static boolean isGeoTransformAvailable(WebSpatialReference sr1, WebSpatialReference sr2)
          Deprecated. As of ArcGIS Server 10.0, instead use ADFUtil.isGeoTransformAvailable(WebSpatialReference, WebSpatialReference)
static WebExtent reaspect(WebExtent extent, double width, double height)
          Deprecated. As of ArcGIS Server 10.0, instead use ADFUtil.reaspect(WebExtent, double, double)
static void setFacesContext(javax.faces.context.FacesContext facesContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT_FAMILY_PREFIX

public static final String COMPONENT_FAMILY_PREFIX
The prefix for name of the family of GIS server web controls.

See Also:
Constant Field Values

COMPONENT_TYPE_PREFIX

public static final String COMPONENT_TYPE_PREFIX
The prefix for name of the component type for GIS server web controls.

See Also:
Constant Field Values

VALIDATOR_PREFIX

public static final String VALIDATOR_PREFIX
The prefix for name of the validators for GIS server web controls.

See Also:
Constant Field Values
Constructor Detail

WebUtil

public WebUtil()
Method Detail

findParentContextControl

public static ContextControl findParentContextControl(javax.faces.component.UIComponent component)
Finds the most immediate ContextControl parent for this component. If a parent context control cannot be found, it returns the first available context on the page.

Parameters:
component - the JSF component
Returns:
ContextControl - the parent context

getWebContext

public static WebContext getWebContext(javax.faces.component.UIComponent component,
                                       String contextId)
If contextId is not null, return the WebContext associated with that ID. Else, find the parent ContextControl for this component and return the associated WebContext. If a parent context control cannot be found, it returns the first available context on the page.

Parameters:
component - the JSF component
contextId - the ID of the WebContext
Returns:
WebContext- the WebContext

getWebContext

public static WebContext getWebContext(javax.faces.component.UIComponent component)
Finds the parent ContextControl for this component and returns the associated WebContext. If a parent context control cannot be found, it returns the first available context control on the page.

Parameters:
component - the JSF component
Returns:
WebContext- the WebContext

getWebContext

public static WebContext getWebContext(javax.faces.context.FacesContext facesContext,
                                       String contextId)
Finds the WebContext in the request map of this FacesContext.

Parameters:
facesContext - the FacesContext
contextId - the ID of the WebContext stored in session
Returns:
WebContext- the WebContext

getComponentById

public static javax.faces.component.UIComponent getComponentById(String id)
Returns the UIComponent object matching the given id; The method will search all UIComponent objects under the root view of current context; Null will be returned if no UIComponent object with the given id is found;

Parameters:
id - - A String
Returns:
- a javax.faces.component.UIComponent object.

getComponentById

public static javax.faces.component.UIComponent getComponentById(javax.faces.component.UIComponent comp,
                                                                 String id)
Returns the UIComponent object matching the given id; The method will only search the children components under the given UIComponent; Null will be returned if no UIComponent object with the id is found;

Parameters:
id - - A String
Returns:
- a javax.faces.component.UIComponent object.

getAllChildren

public static List<javax.faces.component.UIComponent> getAllChildren(javax.faces.component.UIComponent comp)
The method will retrieve all children components under given component.

Parameters:
comp - - a javax.faces.component.UIComponent
Returns:
- a list of UIComponent object;

getAllTaskControls

public static Map<String,TaskControl> getAllTaskControls(javax.faces.component.UIComponent component)
Returns all Task controls in a map with id and object pair under the given component.

Parameters:
component - - an UIComponent object
Returns:
- a java.util.Map object with id and TaskControl object pair.

getClient

public static String getClient(javax.faces.context.FacesContext facesContext)
Extracts the user-agent header from the HTTP Servlet request. If the agent is netscape, it returns the string "netscape". If the agent is IE, it returns the string "ie". If the agent is Opera, it returns the string "opera". Otherwise, it returns the user-agent header as defined in the header.

Parameters:
facesContext - the FacesContext
Returns:
String- the client

isCommonResourcesRegistered

public static boolean isCommonResourcesRegistered(javax.faces.context.FacesContext facesContext)
Indicates if the common resources have been registered in this request. If not registered, a request attribute is set indicating that the resources have been registered.

Parameters:
facesContext - the FacesContext
Returns:
boolean- an indicator if the common resources (e.g. JavaScript files) have been registered in this request

getFacesContext

public static javax.faces.context.FacesContext getFacesContext()

getExternalContext

public static javax.faces.context.ExternalContext getExternalContext()

setFacesContext

public static void setFacesContext(javax.faces.context.FacesContext facesContext)

getRequestContextPath

public static String getRequestContextPath()

getMimeURL

public static String getMimeURL(String id,
                                byte[] mimeData,
                                WebSession webSession)
Returns the URL for MIME data.

Parameters:
id - unique id for the control
mimeData - the MIME data byte stream
webSession - the WebSession
Returns:
String- the URL of the MIME data

getMimeURL

public static String getMimeURL(String id,
                                WebSession webSession)

getTileURL

public static String getTileURL(String id,
                                Object value,
                                WebSession webSession,
                                String tileImageFormat)
Returns the URL for Tile data.

Parameters:
id - unique id for the control
value - the tile information store in the session object
webSession - the WebSession
tileImageFormat - the format of the tiled images. (For ex. jpg, png, etc.)
Returns:
String- the URL of the Tile data

getTileURL

public static String getTileURL(String id,
                                String value,
                                WebSession webSession)
Returns the URL for Tile data.

Parameters:
id - unique id for the control
value - the virtual directory URL string to store in the session object
webSession - the WebSession
Returns:
String- the URL of the Tile data

getMimeId

public static String getMimeId(Object obj)
Return the unique identifier used for MIME data.

Parameters:
obj - the control data object
Returns:
String- the unique string identifier

getResource

public static URL getResource(String name)
Finds the resource with the given name.

Parameters:
name - The resource name
Returns:
A URL object for reading the resource, or null if the resource could not be found or the invoker does not have adequate privileges to get the resource.

isGeoTransformAvailable

@Deprecated
public static boolean isGeoTransformAvailable(WebSpatialReference sr1,
                                                         WebSpatialReference sr2)
Deprecated. As of ArcGIS Server 10.0, instead use ADFUtil.isGeoTransformAvailable(WebSpatialReference, WebSpatialReference)

Indicates whether a geotransformation is available between these two spatial references. Use this method to find out if two resources with different spatial references can be used together, or if the WebContext can be safely reprojected to a new spatial reference.

Parameters:
sr1 - from spatial reference
sr2 - to spatial reference
Returns:
boolean true, if geotransformation available
See Also:
WebContext.setSpatialReference(WebSpatialReference)

reaspect

@Deprecated
public static WebExtent reaspect(WebExtent extent,
                                            double width,
                                            double height)
Deprecated. As of ArcGIS Server 10.0, instead use ADFUtil.reaspect(WebExtent, double, double)

Adjusts the current envelope based on the aspect ratio of the given width and height.

Parameters:
extent - the extent to be reaspect
width - the image width in pixels.
height - the image height in pixels.
Returns:
the reaspected extent

copy

@Deprecated
public static <T extends Serializable> T copy(T src)
                                   throws ADFException
Deprecated. As of ArcGIS Server 10.0, instead use ADFUtil.copy(Serializable)

Create a copy of the specified Serializable object.

Parameters:
src - the object to create a copy
Returns:
the copy of the specified object
Throws:
ADFException