com.webmethods.caf.faces.data.object
Class ELPropertyContentProvider

java.lang.Object
  extended by com.webmethods.caf.faces.bean.PageFlowScopeAdapter
      extended by com.webmethods.caf.faces.data.object.ELPropertyContentProvider
All Implemented Interfaces:
IPageFlowScopeAdapter, IContentProvider, IUpdateableContentProvider, Serializable
Direct Known Subclasses:
BoundChildrenNode.PermissiveContentProviderWrapper, ScalarTableContentProvider

public class ELPropertyContentProvider
extends PageFlowScopeAdapter
implements Serializable, IUpdateableContentProvider

IUpdateableContentProvider implementation that wraps any object and accesses its properties using faces' expression language.

 class Item {
                public int getId();
                public String getName(); 
 };
 
 Item item = new Item("1", "First Item");
 IUpdateableContentProvider provider = new ELPropertyContentProvider(item);
 Integer itemId = (Integer)provider.getValue("id"); // returns 1
 String itemName = (String)provider.getValue("name"); // return "First Item"
 provider.setValue("name", "The new name"); // update the items name property
 
 

See Also:
Serialized Form

Field Summary
protected  Object m_o
          Wrapped object
 
Fields inherited from class com.webmethods.caf.faces.bean.PageFlowScopeAdapter
fExpireWithPageFlow
 
Constructor Summary
ELPropertyContentProvider()
          Default constructor.
ELPropertyContentProvider(Object o)
          Initializes with the given object
 
Method Summary
 Object getObject()
          Returns currently wrapped object
 Object[] getPropertyKeys()
          Returns list of properties supported by this content provider.
 Class getType(Object propertyKey)
          Returns java type of the given property
 Object getValue(Object propertyKey)
          Returns value of the given property
 boolean hasProperty(Object propertyKey)
          Checks if the given property is supported by this content provider
 boolean isReadOnly(Object propertyKey)
          Returns true if the given property is readonly.
 void setObject(Object o)
          Sets an object to wrap.
 void setValue(Object propertyKey, Object value)
          Sets new value of the given property
 String toString()
          Returns string representation of content.
 
Methods inherited from class com.webmethods.caf.faces.bean.PageFlowScopeAdapter
getExpireWithPageFlow, setExpireWithPageFlow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_o

protected Object m_o
Wrapped object

Constructor Detail

ELPropertyContentProvider

public ELPropertyContentProvider()
Default constructor. ELPropertyContentProvider.setObject(Object) must be called before use.


ELPropertyContentProvider

public ELPropertyContentProvider(Object o)
Initializes with the given object

Parameters:
o - any object to adapt
Method Detail

toString

public String toString()
Description copied from interface: IContentProvider
Returns string representation of content.

Specified by:
toString in interface IContentProvider
Overrides:
toString in class Object
Returns:
String representation of the wrapped content

getPropertyKeys

public Object[] getPropertyKeys()
Description copied from interface: IContentProvider
Returns list of properties supported by this content provider. Can return Object[0], never null.

Specified by:
getPropertyKeys in interface IContentProvider
Returns:
array of property keys which is typically of type String or Integer

getType

public Class getType(Object propertyKey)
              throws PropertyNotFoundException
Description copied from interface: IContentProvider
Returns java type of the given property

Specified by:
getType in interface IContentProvider
Parameters:
propertyKey - the property key of type String or Integer
Returns:
property java Class
Throws:
PropertyNotFoundException - if property is not supported

getValue

public Object getValue(Object propertyKey)
                throws EvaluationException,
                       PropertyNotFoundException
Description copied from interface: IContentProvider
Returns value of the given property

Specified by:
getValue in interface IContentProvider
Parameters:
propertyKey - the property key of type String or Integer
Returns:
value of the property, can be null
Throws:
EvaluationException - if error during property evaluation
PropertyNotFoundException - if property is not supported

hasProperty

public boolean hasProperty(Object propertyKey)
Description copied from interface: IContentProvider
Checks if the given property is supported by this content provider

Specified by:
hasProperty in interface IContentProvider
Parameters:
propertyKey - property key of type String or Integer
Returns:
true if property is supported

isReadOnly

public boolean isReadOnly(Object propertyKey)
                   throws EvaluationException,
                          PropertyNotFoundException
Description copied from interface: IUpdateableContentProvider

Returns true if the given property is readonly. If it is readonly, IUpdateableContentProvider.setValue(Object, Object) will definitely fail.

Specified by:
isReadOnly in interface IUpdateableContentProvider
Parameters:
propertyKey - property key of type String or Integer
Returns:
true if the property is readonly
Throws:
EvaluationException
PropertyNotFoundException

setValue

public void setValue(Object propertyKey,
                     Object value)
              throws EvaluationException,
                     PropertyNotFoundException
Description copied from interface: IUpdateableContentProvider

Sets new value of the given property

Specified by:
setValue in interface IUpdateableContentProvider
Parameters:
propertyKey - property key of type String or Integer
value - new property value
Throws:
EvaluationException - if error happens during property assigment
PropertyNotFoundException - if property is not found

setObject

public void setObject(Object o)
Sets an object to wrap. Should be called once at initialization time before any other methods are used.


getObject

public Object getObject()
Returns currently wrapped object

Returns:
null if not set