Class ExpressionAttributeDescriptor

All Implemented Interfaces:
Serializable, Comparable

public class ExpressionAttributeDescriptor extends AttributeDescriptor
This descriptor gives the possibility for declaring dynamic default values, means that the given expression will be evaluated at runtime by the bean shell interpreter. Therefore a new parameter 'defaultValueExpression' is introduced. ATTENTION: The normal 'defaultvalue' tag will be treated as ever and will be used as fallback.

Sample definition:

 <attribute qualifier="sampleUser" type="User" metatype="ExpressionAttributeDescriptor">
        <modifiers initial="true" read="true" write="false" optional="false" />
        <persistence type="property" />
        <custom-properties>
                <property name="defaultValueExpression"><value>"de.hybris.platform.jalo.JaloSession.getCurrentSession().getUser()"</value></property>
        </custom-properties>
 </attribute>
 
See Also:
  • Field Details

    • DEFAULT_VALUE_EXPRESSION

      public static final String DEFAULT_VALUE_EXPRESSION
      Parameter which indicates the property for defining the default expression.
      See Also:
  • Constructor Details

    • ExpressionAttributeDescriptor

      public ExpressionAttributeDescriptor()
  • Method Details

    • getDefaultValueExpressionString

      public String getDefaultValueExpressionString()
      Gets the original expression as defined.
      Returns:
      defined expression which will be evaluated and used as default value
    • setDefaultValueExpressionString

      public void setDefaultValueExpressionString(String defaultValueExpression)
      Sets a new expression which will be used instead.
      Parameters:
      defaultValueExpression - new expression
    • getDefaultValueExpression

      public Object getDefaultValueExpression()
      Gets the value evaluated from set expression.
      Returns:
      evaluated value
    • getDefaultValue

      public Object getDefaultValue(SessionContext ctx)
      Gets the default value of this descriptor evaluated from from set expression. if no expression is set or evaluation results in null, the default value of the super descriptor is returned.
      Overrides:
      getDefaultValue in class AttributeDescriptor
      Parameters:
      ctx - the session context specifying the language ( affect for localized attributes only )
      See Also:
    • exportXMLDefinitionDefaultValue

      protected void exportXMLDefinitionDefaultValue(org.znerd.xmlenc.XMLOutputter xout) throws IOException
      Overrides:
      exportXMLDefinitionDefaultValue in class AttributeDescriptor
      Throws:
      IOException