com.ibm.xsp.resource
Class AbstractResource

java.lang.Object
  extended by com.ibm.xsp.complex.ValueBindingObjectImpl
      extended by com.ibm.xsp.resource.AbstractResource
All Implemented Interfaces:
ComponentBindingObject, ValueBindingObject, Resource, javax.faces.component.StateHolder
Direct Known Subclasses:
BundleResource, DojoModulePathResource, DojoModuleResource, GenericHeadResource, LinkResource, MetaDataResource, ScriptResource, StyleSheetResource

public abstract class AbstractResource
extends ValueBindingObjectImpl
implements Resource

Useful superclass for resources


Field Summary
static java.lang.String FAMILY
           
 
Constructor Summary
AbstractResource()
          Construct an AbstractResource instance
 
Method Summary
 void encodeObject(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          A default implementation provided for when this resource implements EncodableObject.
 java.lang.String getFamily()
          Used when this resource implements EncodableObject, see encodeObject(FacesContext, UIComponent).
 java.lang.String getRendererType()
          Used when this resource implements EncodableObject, see encodeObject(FacesContext, UIComponent).
protected  java.lang.Object getServerResourceContents(java.lang.String serverUrl, java.lang.String serverCharset, java.lang.String contentsPropertyValue)
          Utility method used by server-side resources to load the contents of the resource.
 java.lang.String getUniqueId()
           
 boolean isRendered()
          Returns the rendered property
protected  java.lang.Object loadContents(java.lang.String url, java.lang.String charset)
          Load the contents from the URI specified source.
 void restoreState(javax.faces.context.FacesContext context, java.lang.Object state)
           
 java.lang.Object saveState(javax.faces.context.FacesContext context)
           
 void setRendered(boolean rendered)
          Set the rendered property of the resource.
 void setRendererType(java.lang.String rendererType)
          Used when this resource implements EncodableObject, see encodeObject(FacesContext, UIComponent).
 
Methods inherited from class com.ibm.xsp.complex.ValueBindingObjectImpl
getComponent, getFacesContext, getValueBinding, isTransient, setComponent, setTransient, setValueBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FAMILY

public static final java.lang.String FAMILY
See Also:
Constant Field Values
Constructor Detail

AbstractResource

public AbstractResource()
Construct an AbstractResource instance

Method Detail

getUniqueId

public java.lang.String getUniqueId()

isRendered

public boolean isRendered()
Returns the rendered property

Specified by:
isRendered in interface Resource
Returns:
Returns the rendered.

setRendered

public void setRendered(boolean rendered)
Description copied from interface: Resource
Set the rendered property of the resource.

Specified by:
setRendered in interface Resource
Parameters:
rendered - The new rendered flag to set.

getServerResourceContents

protected java.lang.Object getServerResourceContents(java.lang.String serverUrl,
                                                     java.lang.String serverCharset,
                                                     java.lang.String contentsPropertyValue)
                                              throws java.io.IOException
Utility method used by server-side resources to load the contents of the resource. A server-side resource usually references a file in the current NSF, then loads and publishes the contents of that resource while the UIComponent tree is processed on the server. Methods using this utility should probably check isRendered() before invoking this method. The method loadContents(String, String) is used to load the URL contents. The loaded contents of the server URL are usually cached, but if persistence is enabled the loaded contents are discarded instead of serialized.

Parameters:
serverUrl - path or URL to resource to be loaded on the server
serverCharset - character set of the resource to be loaded on the server
contentsPropertyValue - value provided through the "contents" property in the XPage source, to be used instead of the serverUrl contents.
Returns:
the loaded resource, or null if the serverUrl is empty
Throws:
java.io.IOException
FacesExceptionEx

loadContents

protected java.lang.Object loadContents(java.lang.String url,
                                        java.lang.String charset)
                                 throws java.io.IOException
Load the contents from the URI specified source.

Throws:
java.io.IOException

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext context)
Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class ValueBindingObjectImpl

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         java.lang.Object state)
Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class ValueBindingObjectImpl

encodeObject

public void encodeObject(javax.faces.context.FacesContext context,
                         javax.faces.component.UIComponent component)
                  throws java.io.IOException
A default implementation provided for when this resource implements EncodableObject. Implementors should call setRendererType(String) in their constructor. It will delegate to a ResourceRenderer for the current family and rendererType.

Throws:
java.io.IOException

getFamily

public java.lang.String getFamily()
Used when this resource implements EncodableObject, see encodeObject(FacesContext, UIComponent).

Returns:

getRendererType

public java.lang.String getRendererType()
Used when this resource implements EncodableObject, see encodeObject(FacesContext, UIComponent).

Returns:
the rendererType

setRendererType

public void setRendererType(java.lang.String rendererType)
Used when this resource implements EncodableObject, see encodeObject(FacesContext, UIComponent).

Parameters:
rendererType - the rendererType to set