Java Reference
In-Depth Information
Figure 15.5: Form getting redisplayed on invalid input
Figure 15.6: Showing validation errors in the Ajax response
Was That an Ajax Request?
By implementing the
ValidationErrorHandler
interface, you can
return a resolution to a page fragment instead of the default
getContext().getSourcePageResolution
( ). In this and other situa-
tions, you may want to do something different according to the
request being Ajax or non-Ajax.
One way of finding out whether you're dealing with an Ajax
request is by looking at the
X-Requested-With
request header. This
header has a value of
XMLHttpRequest
for Ajax requests:
String header =
getContext().getRequest().getHeader("X-Requested-With");
if
(header !=
null
&& header.equalsIgnoreCase("XMLHttpRequest")) {
// it's an AJAX request!
}
Search WWH ::
Custom Search