org.qi4j.library.struts2
Class Qi4jPropertyAccessor

java.lang.Object
  extended by ognl.ObjectPropertyAccessor
      extended by org.qi4j.library.struts2.Qi4jPropertyAccessor
All Implemented Interfaces:
ognl.PropertyAccessor

public class Qi4jPropertyAccessor
extends ognl.ObjectPropertyAccessor

An implementation of the ObjectPropertyAccessor that provides conversion for Qi4j properties. The typical way that OGNL gets/sets object attributes is by finding the corresponding JavaBean getter/setter methods. This ObjectPropertyAccessor checks if there is a Qi4j property on the Composite and if there is uses the properties get/set methods.

When setting Property values, if a ConstraintViolationException is thrown it is added to the context so that it can be processed and by the ConstraintViolationInterceptor, similar to how conversion exceptions are handled by the ConversionErrorInterceptor

When setting Association values, we attempt to convert the value to the association type using the normal XWork converter mechanisms. If the type is an EntityComposite, we already have a converter registered EntityCompositeConverter to handle conversion from a string identity to an object. If the type is not an EntityComposite, but the actual values are EntityComposites, you can register the EntityCompositeConverter for your type in your xwork-conversion.properties file.

NOTE: We can't do this as a regular converter because Qi4j composites doesn't (nor should it be) following the JavaBean standard. We might be able to only override the getProperty() method here and have regular converters for Property, Association and SetAssociation but I haven't tried that yet so it may not work as expected.

TODO: Doesn't yet handle ManyAssociations, but these shouldn't be too hard to add


Constructor Summary
Qi4jPropertyAccessor()
           
 
Method Summary
 Object getProperty(Map aContext, Object aTarget, Object aPropertyName)
           
protected  void handleConstraintViolation(Map aContext, Object aTarget, String aPropertyName, Object aPropertyValue, Collection<ConstraintViolation> violations)
           
 void setProperty(Map aContext, Object aTarget, Object aPropertyName, Object aPropertyValue)
           
 
Methods inherited from class ognl.ObjectPropertyAccessor
getPossibleProperty, getPropertyClass, getSourceAccessor, getSourceSetter, hasGetProperty, hasGetProperty, hasSetProperty, hasSetProperty, setPossibleProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Qi4jPropertyAccessor

public Qi4jPropertyAccessor()
Method Detail

getProperty

public final Object getProperty(Map aContext,
                                Object aTarget,
                                Object aPropertyName)
                         throws ognl.OgnlException
Specified by:
getProperty in interface ognl.PropertyAccessor
Overrides:
getProperty in class ognl.ObjectPropertyAccessor
Throws:
ognl.OgnlException

setProperty

public final void setProperty(Map aContext,
                              Object aTarget,
                              Object aPropertyName,
                              Object aPropertyValue)
                       throws ognl.OgnlException
Specified by:
setProperty in interface ognl.PropertyAccessor
Overrides:
setProperty in class ognl.ObjectPropertyAccessor
Throws:
ognl.OgnlException

handleConstraintViolation

protected final void handleConstraintViolation(Map aContext,
                                               Object aTarget,
                                               String aPropertyName,
                                               Object aPropertyValue,
                                               Collection<ConstraintViolation> violations)