Dashboard > OGNL > Home > Property Accessor
  OGNL Log In View a printable version of the current page.  
  Property Accessor
Added by tm_jee, last edited by tm_jee on Dec 27, 2007  (view change)
Labels: 
(None)

When navigating an OGNL expression many of the elements that are found are properties. Properties can be many things depending on the object being accessed. Most of the time these property names resolve to JavaBeans properties that conform to the set/get pattern. Other objects (such as Map) access properties as keyed values. Regardless of access methodology the OGNL syntax remains the same. Under the hood, however, there are PropertyAccessor objects that handle the conversion of property name to an actual access to an objects' properties.

public interface PropertyAccessor
{
    Object getProperty( Map context, Object target, Object name ) throws OgnlException;
    void setProperty( Map context, Object target, Object name, Object value ) throws OgnlException;
}

You can set a property accessor on a class-by-class basis using

OgnlRuntime.setPropertyAccessor(clazz, propertyAccessor);

There are default property accessors for Object (which uses JavaBeans patterns to extract properties) and Map (which uses the property name as a key) namely ognl.ObjectPropertyAccessor and ognl.MapPropertyAccessor respectively.

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request - Contact Administrators