Package com.axelor.rpc
Class Context
java.lang.Object
javax.script.SimpleBindings
com.axelor.rpc.Context
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 SaleOrderThe 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.
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChangeListener
(PropertyChangeListener listener) <T> T
Convert the context as lazy entity of the given type.boolean
containsKey
(Object key) Class
<?> Get parent context.protected Object
protected Object
Methods inherited from class javax.script.SimpleBindings
clear, containsValue, entrySet, isEmpty, keySet, putAll, remove, size, values
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
Context
Create a newContext
for the given bean class using the given context values.- Parameters:
values
- the context valuesbeanClass
- the context bean class
-
Context
Create a newContext
for the given bean class.- Parameters:
beanClass
- the context bean class
-
Context
Create a newContext
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 idbeanClass
- the record entity class
-
-
Method Details
-
addChangeListener
-
getTarget
-
validate
-
getParent
Get parent context.- Returns:
- the parent context if exist
-
getContextClass
-
asType
Convert the context as lazy entity of the given type.- Parameters:
type
- the expected type- Returns:
- lazy initialized entity
-
containsKey
- Specified by:
containsKey
in interfaceBindings
- Specified by:
containsKey
in interfaceMap<String,
Object> - Overrides:
containsKey
in classSimpleBindings
-
get
-
put
-