-
Notifications
You must be signed in to change notification settings - Fork 64
Form Post Exception Handling
Ralph Schaer edited this page Jul 10, 2012
·
9 revisions
Methods annotated with @ExtDirectMethod(ExtDirectMethodType.FORM_POST) 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;
}
}
- Introduction
- Changelog 1.7.x
- Setup Maven
- Configuration
- Server Methods
- Model Generator
- Model Generator APT
- Development
- Links