Class Context

  • All Implemented Interfaces:
    Map<String,​Object>, Bindings

    public class Context
    extends SimpleBindings
    The Context class represents an ActionRequest context.

    The request context is mapped to a proxy instance of the bean class on which the action is being performed. The proxy instance can be accessed via asType(Class) method.

    Example (Java):

     Context context = request.getContext();
     SaleOrderLine soLine = context.asType(SaleOrderLine.class);
     SaleOrder so = context.getParentContext().asType(SaleOrder.class);
     
    Example (Groovy):
     def context = request.context
     def soLine = context as SaleOrderLine
     def so = context.parentContext as SaleOrder
     
    The instance returned from the context is a detached proxy object and should not be used with JPA/Hibernate session. It's only for convenience to get the context values using the bean methods.
    • Constructor Detail

      • Context

        public Context​(Map<String,​Object> values,
                       Class<?> beanClass)
        Create a new Context for the given bean class using the given context values.
        Parameters:
        values - the context values
        beanClass - the context bean class
      • Context

        public Context​(Class<?> beanClass)
        Create a new Context for the given bean class.
        Parameters:
        beanClass - the context bean class
      • Context

        public Context​(Long id,
                       Class<?> beanClass)
        Create a new Context for a record by given id.

        This is useful when we have to use custom fields defined for an entity from business code.

        Parameters:
        id - the record id
        beanClass - the record entity class