Skip to content

Instantly share code, notes, and snippets.

@msosvi
Created February 13, 2012 21:41
Show Gist options
  • Save msosvi/1820713 to your computer and use it in GitHub Desktop.
Save msosvi/1820713 to your computer and use it in GitHub Desktop.
Ajax handler for Apache Trinidad.
package net.enlosdetalles.spring;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.js.ajax.SpringJavascriptAjaxHandler;
/**
* Ajax handler for Apache Trinidad.
*
*/
public class ApacheTrinidadAjaxHandler extends SpringJavascriptAjaxHandler {
@Override
protected boolean isAjaxRequestInternal(HttpServletRequest request, HttpServletResponse response) {
String trXHRMessageHeader = request.getHeader("Tr-XHR-Message"); //Trinidad 1.x header
String facesRequestHeader = request.getHeader("Faces-Request"); //Trinidad 2.x header
if ((trXHRMessageHeader!=null && trXHRMessageHeader.equals("true")) ||
(facesRequestHeader!=null && facesRequestHeader.equals("partial/ajax"))) {
return true;
} else {
return super.isAjaxRequestInternal(request, response);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment