com.ibm.xsp.util
Class DataPublisher

java.lang.Object
  extended by com.ibm.xsp.util.DataPublisher

public class DataPublisher
extends java.lang.Object

This is used by UIComponents to publishing "var"s to the requestMap, and saving any previous value that was present under that name in a list of DataPublisher.ShadowedObjects. Each push or publish method should be paired with the corresponding pop or revoke method, so that once this control has finished its own rendering, later controls on the XPage will see the old value for the variable name. The main methods of interest are the push/pop methods. The publish/revoke methods are only provided as a convenience; they provide default push/pop behaviors for controls that do not have any getVar method, just publish the values associated with the interface FacesDataProvider, the FacesPropertyProvider control, and for the UIViewRoot control, it also handles the UIViewRootEx.getResources() vars.


Nested Class Summary
static class DataPublisher.ShadowedObject
          Saves any previous value that was present in the RequestMap
 
Field Summary
static java.lang.String DATASOURCE
          The data source var suffix; often data sources will publish their data source object under the variable name: var+".DATASOURCE"
so that the data source object can be retrieved by controls that need to access the data source itself rather than the data that it publishes.
static java.lang.String READONLY
          The readonly var suffix; often data sources will publish a boolean under the variable name: var+".READONLY"
indicating whether the data source is read-only.
 
Constructor Summary
DataPublisher()
           
 
Method Summary
 java.util.List<DataPublisher.ShadowedObject> createShadowedList()
           
 void encodeDatasources(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Data source rendering.
protected  javax.faces.context.FacesContext getFacesContext()
          Available to be called by subclasses, the FacesContext for this request.
protected  java.util.Map<java.lang.String,java.lang.Object> getRequestMap()
           
 boolean isAllowCreateViewPublish(javax.faces.component.UIComponent component)
          Examines the control ancestors to see if this control should publish during the createView phase.
 void popCompositeData(java.util.List<DataPublisher.ShadowedObject> shadowed, javax.faces.component.UIComponent component, PropertyMap propertyMap)
           
 void popDataSource(java.util.List<DataPublisher.ShadowedObject> shadowed, javax.faces.component.UIComponent component, DataSource data)
          Helper method to pop a component data instance
 void popObjects(java.util.List<DataPublisher.ShadowedObject> shadowed)
           
 void popPublishingObject(java.util.List<DataPublisher.ShadowedObject> shadowed, javax.faces.component.UIComponent component, DataPublishingObject resource)
          Helper method to pop a component data instance
 java.util.List<DataPublisher.ShadowedObject> publishControlData(javax.faces.component.UIComponent component)
          Expose the component data and and component data context values associated with the specified component as request scoped variables.
 void pushCompositeData(java.util.List<DataPublisher.ShadowedObject> shadowedData, javax.faces.component.UIComponent component, PropertyMap propertyMap)
           
 java.util.List<DataPublisher.ShadowedObject> pushDataSource(javax.faces.component.UIComponent component, DataSource data)
          Helper method to push a component data instance
 void pushObject(java.util.List<DataPublisher.ShadowedObject> shadowed, java.lang.String var, java.lang.Object data)
          Helper method to push an object into the request map
 void pushPublishingObject(javax.faces.component.UIComponent component, java.util.List<DataPublisher.ShadowedObject> shadowedData, DataPublishingObject bundle)
           
 java.util.List<DataPublisher.ShadowedObject> pushShadowObjects(java.util.List<DataPublisher.ShadowedObject> shadowed, java.lang.String... vars)
          For the given variable names, if non-empty, save the request map value of the variable to the shadowed list, creating the list if it is null.
 void revokeControlData(java.util.List<DataPublisher.ShadowedObject> shadowedData, javax.faces.component.UIComponent component)
          Remove the component data and and component data context values associated with the specified component from the request scope.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READONLY

public static final java.lang.String READONLY
The readonly var suffix; often data sources will publish a boolean under the variable name: var+".READONLY"
indicating whether the data source is read-only.

See Also:
Constant Field Values

DATASOURCE

public static final java.lang.String DATASOURCE
The data source var suffix; often data sources will publish their data source object under the variable name: var+".DATASOURCE"
so that the data source object can be retrieved by controls that need to access the data source itself rather than the data that it publishes. This is the mechanism used by the repeating controls to find ModelDataSource implementers corresponding to the value being repeated over, so that the ModelDataSource.getDataModel() data model can be used to iterate through the data source.

See Also:
Constant Field Values
Constructor Detail

DataPublisher

public DataPublisher()
Method Detail

getFacesContext

protected javax.faces.context.FacesContext getFacesContext()
Available to be called by subclasses, the FacesContext for this request.

Returns:
the context

getRequestMap

protected java.util.Map<java.lang.String,java.lang.Object> getRequestMap()
Returns:

isAllowCreateViewPublish

public boolean isAllowCreateViewPublish(javax.faces.component.UIComponent component)
Examines the control ancestors to see if this control should publish during the createView phase. If the panel is nested in an iterator, then the data should not be evaluated and published here as the the iterator is *not* iterating, so the index and current item will not be available. FacesDataIterators do not iterate during the createView phase.

Parameters:
component -
Returns:

publishControlData

public java.util.List<DataPublisher.ShadowedObject> publishControlData(javax.faces.component.UIComponent component)
                                                                throws javax.faces.FacesException
Expose the component data and and component data context values associated with the specified component as request scoped variables.

Throws:
javax.faces.FacesException

pushCompositeData

public void pushCompositeData(java.util.List<DataPublisher.ShadowedObject> shadowedData,
                              javax.faces.component.UIComponent component,
                              PropertyMap propertyMap)

pushPublishingObject

public void pushPublishingObject(javax.faces.component.UIComponent component,
                                 java.util.List<DataPublisher.ShadowedObject> shadowedData,
                                 DataPublishingObject bundle)
                          throws javax.faces.FacesException
Throws:
javax.faces.FacesException

popPublishingObject

public void popPublishingObject(java.util.List<DataPublisher.ShadowedObject> shadowed,
                                javax.faces.component.UIComponent component,
                                DataPublishingObject resource)
Helper method to pop a component data instance

Parameters:
component - TODO

revokeControlData

public void revokeControlData(java.util.List<DataPublisher.ShadowedObject> shadowedData,
                              javax.faces.component.UIComponent component)
                       throws javax.faces.FacesException
Remove the component data and and component data context values associated with the specified component from the request scope.

Throws:
javax.faces.FacesException

popCompositeData

public void popCompositeData(java.util.List<DataPublisher.ShadowedObject> shadowed,
                             javax.faces.component.UIComponent component,
                             PropertyMap propertyMap)

pushShadowObjects

public java.util.List<DataPublisher.ShadowedObject> pushShadowObjects(java.util.List<DataPublisher.ShadowedObject> shadowed,
                                                                      java.lang.String... vars)
For the given variable names, if non-empty, save the request map value of the variable to the shadowed list, creating the list if it is null. Paired with popObjects(List). The difference between this and pushObject(List, String, Object) is that this doesn't actually publish a value in the request map. It only saves the old values that were present under the variable names. Normally you would use pushObject(List, String, Object) instead, which both publishes the new value and saves the old value in the same method. This method is only used in the repeating controls, which first save the old values, then repeatedly publish different new values as they iterate, and finally restore the old values.

Parameters:
shadowed -
vars -
Returns:

pushObject

public void pushObject(java.util.List<DataPublisher.ShadowedObject> shadowed,
                       java.lang.String var,
                       java.lang.Object data)
Helper method to push an object into the request map


createShadowedList

public java.util.List<DataPublisher.ShadowedObject> createShadowedList()

popObjects

public void popObjects(java.util.List<DataPublisher.ShadowedObject> shadowed)

pushDataSource

public java.util.List<DataPublisher.ShadowedObject> pushDataSource(javax.faces.component.UIComponent component,
                                                                   DataSource data)
Helper method to push a component data instance


popDataSource

public void popDataSource(java.util.List<DataPublisher.ShadowedObject> shadowed,
                          javax.faces.component.UIComponent component,
                          DataSource data)
Helper method to pop a component data instance


encodeDatasources

public void encodeDatasources(javax.faces.context.FacesContext context,
                              javax.faces.component.UIComponent component)
                       throws java.io.IOException
Data source rendering.

Throws:
java.io.IOException