-
Notifications
You must be signed in to change notification settings - Fork 64
Configuration
With the class ch.ralscha.extdirectspring.controller.Configuration it is possible to tweak different aspects of ExtDirectSpring.
The three properties timeout, maxRetries and enableBuffer configure a RemotingProvider. Description about these properties.
<bean id="extDirectSpringConfiguration"
class="ch.ralscha.extdirectspring.controller.Configuration"
p:timeout="12000" p:maxRetries="10" p:enableBuffer="false"/>
A call to api.js is sending these parameters, if specified, to the client as part of the remoting configuration.
Example output of a call to api-debug.js with the above configuration present in the Spring context.
Ext.app.REMOTING_API = {
"url" : "/controller/router",
"type" : "remoting",
"actions" : {
"treeProvider" : [ {
"name" : "getTree",
"len" : 1
} ]
},
"timeout" : 12000,
"maxRetries" : 10,
"enableBuffer" : false
};
If not specified the server does not send these properties to the client. RemotingProvider will then use these default values: timeout=30000, maxRetries=1 and enableBuffer=10
Defaults to false. Setting this property to true will wrap every call to a @ExtDirectMethod in a synchronized block. This is useful when the server method needs to manipulate session objects.
<bean id="extDirectSpringConfiguration"
class="ch.ralscha.extdirectspring.controller.Configuration"
p:synchronizeOnSession="true"
Instead of globally turn on this feature, every method can individually specify the synchronizeOnSession with the @ExtDirectMethod annotation.
@ExtDirectMethod(value = ExtDirectMethodType.STORE_MODIFY, synchronizeOnSession=true)
public List<User> create(List<User> newUsers) {
//...
}
FORM_POST methods do not support this feature.
This property specifies that the Jackson ObjectMapper should work like in version 1.0.x and write the response directly into the http servlet response without setting the http header Content-Length (true). If set to false (default) the ObjectMapper first writes the response into an internal buffer, sets the Content-Length header and then writes the response into the http servlet response.
Instead of globally turn on this feature every method can individually configure the streamResponse property with the @ExtDirectMethod annotation.
If an exception happens on the server and there is no special configuration present the server sends this response back to the client. message contains the text "Server Error" and type the text "exception".
[
{
"method": "method4",
"action": "remoteProviderSimple",
"tid": 2,
"message": "Server Error",
"type": "exception"
}
]
To tweak this behavior add a bean with id extDirectSpringConfiguration and type ch.ralscha.extdirectspring.controller.Configuration to the Spring context.
<context:component-scan base-package="ch.ralscha.extdirectspring" />
<mvc:annotation-driven />
<bean id="extDirectSpringConfiguration"
class="ch.ralscha.extdirectspring.controller.Configuration"
p:defaultExceptionMessage="Panic!!!"
p:sendExceptionMessage="false"
p:sendStacktrace="true">
<property name="exceptionToMessage">
<map>
<entry key="java.lang.IllegalArgumentException"
value="illegal argument"/>
<entry key="org.springframework.beans.factory.NoSuchBeanDefinitionException">
<null/>
</entry>
</map>
</property>
</bean>
| defaultExceptionMessage | Defines the default exception message. Field *message* in the response | Default: 'Server Error' |
| sendExceptionMessage | If true sends exception.getMessage() back. Field *message* in the response | Default: false |
| sendStacktrace | If true sends the whole stacktrace in the field *where* back | Default: false |
| exceptionToMessage | Mapping from exception class (key) to message (value) | Default: empty |
Rules for response field message:
- If there is a mapping for the exception in exceptionToMessage and the value is not null send this value.
- If there is a mapping for the exception in exceptionToMessage and the value is null send exception.getMessage().
- If there is no mapping and sendExceptionMessage is true send exception.getMessage().
- If there is no mapping and sendExceptionMessage is false send defaultExceptionMessage.
- Introduction
- Changelog 1.7.x
- Setup Maven
- Configuration
- Server Methods
- Model Generator
- Model Generator APT
- Development
- Links