com.ibm.xsp.model
Class AbstractDataSource

java.lang.Object
  extended by com.ibm.xsp.complex.ValueBindingObjectImpl
      extended by com.ibm.xsp.model.AbstractDataSource
All Implemented Interfaces:
ComponentBindingObject, ValueBindingObject, DataPublishingObject, DataSource, javax.faces.component.StateHolder
Direct Known Subclasses:
AbstractDocumentDataSource, AbstractViewDataSource

public abstract class AbstractDataSource
extends ValueBindingObjectImpl
implements DataSource


Nested Class Summary
protected static class AbstractDataSource.RuntimeProperties
           
 
Field Summary
static java.lang.String[] NO_VARS
           
 
Constructor Summary
AbstractDataSource()
          Construct an AbstractDataSource instance
 
Method Summary
protected  void beginRuntimeProperties()
          Initialize RuntimeProperties
protected abstract  java.lang.String composeUniqueId()
          Compute a unique ID for shared documents.
protected  java.lang.String computeUniqueBeanId()
          Compute an unique ID used by the data source when the document is not shared.
protected  AbstractDataSource.RuntimeProperties createRuntimeProperties()
          Create a new AbstractDataSource.RuntimeProperties instance
protected  void endRuntimeProperties()
          Reset the current Runtime preperties to null
 java.lang.String getBeanId()
          Get the bean id.
 DataContainer getDataContainer()
          Return the associated data object
protected  DataContainer getDataContainer(javax.faces.context.FacesContext context)
           
abstract  java.lang.Object getDataObject()
          Return the default data object
 java.lang.String getEffectiveScope()
          Same as getScope() only defaulting to "view" if null.
 java.lang.String getRequestParamPrefix()
          Return the request parameter prefix to be used by this data source.
protected  AbstractDataSource.RuntimeProperties getRuntimeProperties()
          Return the current Runtime Properties
 java.lang.String getScope()
          Return the scope identifier under which the data object will be stored.
 java.lang.String getUniqueId()
          Get the unique Id for this data source.
 java.lang.String getVar()
          Return the request-scope attribute under which the data object will be exposed.
 java.lang.String[] getVars()
          Return the request-scope attribute names under which various objects associated with this data source will be exposed, including DataSource.getVar() variable name.
protected  UIViewRootEx getViewRoot(javax.faces.context.FacesContext context)
           
protected  boolean hasRuntimeProperties()
          The data source needs its parameters to be computed just once when the data is first accessed, and every time the page is rendered again.
protected  void initializeRuntimeProperties(AbstractDataSource.RuntimeProperties rtProps)
          Initialize Runtime Properties.
protected  boolean isDataShared()
          Check if the document used by this data source can be shared.
 boolean isIgnoreRequestParams()
          /** Return true if request parameters should be ignored .
protected  boolean isNestedInUIIterator()
          Check if an ancestor component for the component this datasource is associated with is Data Iterator, e.g UIData or UIDataIterator
abstract  boolean isReadonly()
          Return true if this is a read only data object
abstract  DataContainer load(javax.faces.context.FacesContext context)
          Load the associated data container
 void popData(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.util.Map<java.lang.String,java.lang.Object> requestMap)
          Pop the data associated with this data source from the request map, note, if values were added to the shadowedData list during DataPublishingObject.pushData(FacesContext, UIComponent, Map, List), then it is not necessary to remove them from the request map in this method (as the calling class will remove them).
protected  java.lang.String prefixRequestParam(java.lang.String paramName)
           
 void pushData(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.util.Map<java.lang.String,java.lang.Object> requestMap, java.util.List<DataPublisher.ShadowedObject> shadowedData)
          Push the data associated with this data source into the request map
 void putDataContainer(javax.faces.context.FacesContext facesContext, DataContainer data)
           
abstract  void readRequestParams(javax.faces.context.FacesContext context, java.util.Map<java.lang.String,java.lang.Object> requestMap)
          Read the request parameters for this data source
 void refresh()
          Refresh the current state of the data object
protected  void removeBean(javax.faces.context.FacesContext facesContext)
           
 boolean removeBean(javax.faces.context.FacesContext facesContext, java.lang.String scope)
          Remove the bean if it correspond to the scope parameter.
 void restoreState(javax.faces.context.FacesContext context, java.lang.Object state)
           
 boolean save(javax.faces.context.FacesContext context, boolean removeFromManager)
          Save the current state of the data object
abstract  boolean save(javax.faces.context.FacesContext context, DataContainer data)
          Save the current state of the data object
 java.lang.Object saveState(javax.faces.context.FacesContext context)
           
 void setIgnoreRequestParams(boolean ignoreRequestParams)
          Set a flag to indicate if request parameters should be ignored.
 void setRequestParamPrefix(java.lang.String prefix)
          Set the request parameter prefix to be used by this data source.
 void setScope(java.lang.String scope)
          Set the scope identifier under which the data object will be stored.
 void setVar(java.lang.String var)
          Set the request-scope attribute under which the data object will be exposed.
 
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

NO_VARS

public static final java.lang.String[] NO_VARS
Constructor Detail

AbstractDataSource

public AbstractDataSource()
Construct an AbstractDataSource instance

Method Detail

getBeanId

public final java.lang.String getBeanId()
Get the bean id. The bean id is the identifier that identifies an entry in the scope map. It can be either a unique identifier for the datasource instance if the data is not shared with other datasources, or it can be the unique id.

Specified by:
getBeanId in interface DataSource

getUniqueId

public final java.lang.String getUniqueId()
Get the unique Id for this data source. This id is defined on the parameters used to load the data. It is predictable based on the parameters.

Specified by:
getUniqueId in interface DataSource

isDataShared

protected boolean isDataShared()
Check if the document used by this data source can be shared. This happens when multiple data sources share the same document, within a global scope like the session or application scope


computeUniqueBeanId

protected java.lang.String computeUniqueBeanId()
Compute an unique ID used by the data source when the document is not shared.

Returns:

isNestedInUIIterator

protected boolean isNestedInUIIterator()
Check if an ancestor component for the component this datasource is associated with is Data Iterator, e.g UIData or UIDataIterator

Returns:

composeUniqueId

protected abstract java.lang.String composeUniqueId()
Compute a unique ID for shared documents.

Returns:

hasRuntimeProperties

protected boolean hasRuntimeProperties()
The data source needs its parameters to be computed just once when the data is first accessed, and every time the page is rendered again. This supposes that some data are stored within the data source and retrieved during the different phases. It also supposes that the data are cleared out and recomputed when a new rendering phase is started. That's the reason why we use the the view rendering sequence number But the thing is even more complex when the data is within a repeat, as we have one set of property values per repeated occurrence. For this reason, we use a map that stores all the occurrences.


getRuntimeProperties

protected AbstractDataSource.RuntimeProperties getRuntimeProperties()
Return the current Runtime Properties

Returns:
the current RuntimeProperties

createRuntimeProperties

protected AbstractDataSource.RuntimeProperties createRuntimeProperties()
Create a new AbstractDataSource.RuntimeProperties instance

Returns:
new RuntimeProperties

initializeRuntimeProperties

protected void initializeRuntimeProperties(AbstractDataSource.RuntimeProperties rtProps)
Initialize Runtime Properties. Empty method, does nothing.

Parameters:
rtProps - Runtime Properties

beginRuntimeProperties

protected void beginRuntimeProperties()
Initialize RuntimeProperties


endRuntimeProperties

protected void endRuntimeProperties()
Reset the current Runtime preperties to null


getVars

public java.lang.String[] getVars()
Description copied from interface: DataSource
Return the request-scope attribute names under which various objects associated with this data source will be exposed, including DataSource.getVar() variable name.

Specified by:
getVars in interface DataSource

getVar

public java.lang.String getVar()
Return the request-scope attribute under which the data object will be exposed.

Specified by:
getVar in interface DataSource

setVar

public void setVar(java.lang.String var)
Set the request-scope attribute under which the data object will be exposed.

Specified by:
setVar in interface DataSource

getScope

public java.lang.String getScope()
Return the scope identifier under which the data object will be stored.

Specified by:
getScope in interface DataSource

getEffectiveScope

public java.lang.String getEffectiveScope()
Same as getScope() only defaulting to "view" if null.


setScope

public void setScope(java.lang.String scope)
Set the scope identifier under which the data object will be stored.

Specified by:
setScope in interface DataSource

isIgnoreRequestParams

public boolean isIgnoreRequestParams()
Description copied from interface: DataSource
/** Return true if request parameters should be ignored .

Most data sources have a mechanism where the values of some of their properties can be read from the request parameters to the XPage, for example if you have an XPage containing a document data source and you open that XPage with a URL like /page1.xsp?documentId=AAAA, then the document data source will behave as if it were configured with the "documentId" property set to the value "AAA" in the XPage source.

If you do not want a data source to read property values from the request parameters at the end of the URL, then the data source should be configured with ignoreRequestParameters="true".

A related behavior is, if you have multiple data sources in an XPage, then by default they would both read the same request parameters from the URL and they would both be configured to point to the same document. To avoid that behavior you can configure one or both of the data sources with a request parameter prefix, so the data source reads the parameters values with the specified prefix before their parameter name.

Specified by:
isIgnoreRequestParams in interface DataSource
See Also:
DataSource.isIgnoreRequestParams()

setIgnoreRequestParams

public void setIgnoreRequestParams(boolean ignoreRequestParams)
Set a flag to indicate if request parameters should be ignored.

Specified by:
setIgnoreRequestParams in interface DataSource

getRequestParamPrefix

public java.lang.String getRequestParamPrefix()
Return the request parameter prefix to be used by this data source.

Specified by:
getRequestParamPrefix in interface DataSource
See Also:
DataSource.isIgnoreRequestParams()

setRequestParamPrefix

public void setRequestParamPrefix(java.lang.String prefix)
Set the request parameter prefix to be used by this data source.

Specified by:
setRequestParamPrefix in interface DataSource

getDataContainer

public DataContainer getDataContainer()
Return the associated data object

Specified by:
getDataContainer in interface DataSource

refresh

public void refresh()
Description copied from interface: DataSource
Refresh the current state of the data object

Specified by:
refresh in interface DataSource

save

public boolean save(javax.faces.context.FacesContext context,
                    boolean removeFromManager)
             throws FacesExceptionEx
Save the current state of the data object

Specified by:
save in interface DataSource
Returns:
Throws:
FacesExceptionEx

pushData

public void pushData(javax.faces.context.FacesContext context,
                     javax.faces.component.UIComponent component,
                     java.util.Map<java.lang.String,java.lang.Object> requestMap,
                     java.util.List<DataPublisher.ShadowedObject> shadowedData)
              throws FacesExceptionEx
Description copied from interface: DataPublishingObject
Push the data associated with this data source into the request map

Specified by:
pushData in interface DataPublishingObject
Throws:
FacesExceptionEx

popData

public void popData(javax.faces.context.FacesContext context,
                    javax.faces.component.UIComponent component,
                    java.util.Map<java.lang.String,java.lang.Object> requestMap)
             throws FacesExceptionEx
Description copied from interface: DataPublishingObject
Pop the data associated with this data source from the request map, note, if values were added to the shadowedData list during DataPublishingObject.pushData(FacesContext, UIComponent, Map, List), then it is not necessary to remove them from the request map in this method (as the calling class will remove them). This method should do any further tidying up required.

Specified by:
popData in interface DataPublishingObject
Throws:
FacesExceptionEx

removeBean

public boolean removeBean(javax.faces.context.FacesContext facesContext,
                          java.lang.String scope)
Remove the bean if it correspond to the scope parameter.

Parameters:
facesContext -
scope -

getDataObject

public abstract java.lang.Object getDataObject()
Return the default data object

Returns:

isReadonly

public abstract boolean isReadonly()
Return true if this is a read only data object

Specified by:
isReadonly in interface DataSource

save

public abstract boolean save(javax.faces.context.FacesContext context,
                             DataContainer data)
                      throws FacesExceptionEx
Save the current state of the data object

Throws:
FacesExceptionEx

load

public abstract DataContainer load(javax.faces.context.FacesContext context)
                            throws java.io.IOException
Load the associated data container

Parameters:
context -
Throws:
java.io.IOException

readRequestParams

public abstract void readRequestParams(javax.faces.context.FacesContext context,
                                       java.util.Map<java.lang.String,java.lang.Object> requestMap)
Read the request parameters for this data source

Parameters:
context -

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

getViewRoot

protected UIViewRootEx getViewRoot(javax.faces.context.FacesContext context)

putDataContainer

public void putDataContainer(javax.faces.context.FacesContext facesContext,
                             DataContainer data)

getDataContainer

protected DataContainer getDataContainer(javax.faces.context.FacesContext context)

removeBean

protected void removeBean(javax.faces.context.FacesContext facesContext)

prefixRequestParam

protected java.lang.String prefixRequestParam(java.lang.String paramName)