mirror of
https://github.com/ralscha/extdirectspring.git
synced 2026-10-09 09:18:19 +02:00
Page:
Form Post Exception Handling
Pages
@JsonView
Api
Changelog
Changelog1_0_x
Changelog1_1_x
Changelog1_2_x
Changelog1_3_x
Changelog1_4_x
Changelog1_5_x
Changelog1_6_x
Config Spring Java Config
Config SpringXML
Configuration
Development
Form Load Method
Form Post Exception Handling
Form Post Method
Form Post Method1_0_x
Form Post Method1_1_x
Form Post With Upload
Form Post With Upload1_0_x
Form Post With Upload1_1_x
Home
Links
Migraton1_0_to_1_1
ModelGenerator
ModelGeneratorAPT
Polling Method
SSE Method
Setting Up Spring Java
Setup Maven
Simple Method
Simple Named Parameter Method
Store Modify Method
Store Read Method
Tree Load Method
No results
9
Form Post Exception Handling
İlhan Subaşı edited this page 2019-11-26 10:39:01 +03:00
This article is not relevant if FORM_POST methods are written in the 1.2.1 style.
FORM_POST methods written with the 1.1.x style are handled by the Springframework. That means ExtDirectSpring cannot catch and manage exceptions that are thrown in such methods. For all the other method types ExtDirectSpring catches the exceptions, converts them into json messages and sends them to the client.
To enable the same behaviour for FORM_POST methods it's necessary to add a HandlerExceptionResolver to the application. The code for such a resolver has to contain this line: ExtDirectResponseBuilder.create(request, response).setException(ex).buildAndWrite()
Here a complete example
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
import ch.ralscha.extdirectspring.bean.ExtDirectResponseBuilder;
@Component
public class FormPostExceptionHandler implements HandlerExceptionResolver {
@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response,
final Object handler, Exception ex) {
ExtDirectResponseBuilder.create(request, response)
.setException(ex)
.buildAndWrite();
return null;
}
}
Table of Contents
- Introduction
- Changelog 1.7.x
- Setup Maven
- Configuration
- Server Methods
- Model Generator
- Model Generator APT
- Development
- Links