Indeed, setting a response header in a ForwardResolution subclass works:
return new ForwardResolution(...) {
@Override
public void execute(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
response.setHeader("Stripes-Success", "true");
super.execute(request, response);
}
};
Setting a response header in the JSP also works:
<% response.setHeader("Stripes-Success", "true"); %>
As for reading the header back in jQuery, at first I couldn't figure out
how to get the XmlHttpRequest object back with the response data at the
same time. The 'success' callback gets the data, and the 'complete'
callback gets the xhr; how to get both at once?
It turns out AJAX calls, $.ajax, $.get, $.post etc. all return the xhr
object. So this works:
var xhr = $.post(form.action, params, function(data) {
if (xhr.getResponseHeader('Stripes-Success')) {
$('#people').html(data);
}
else {
$('#form').html(data);
}
});
Thanks all (Levi, Oscar, John, and Aaron on IRC) for your help!
Cheers,
Freddy
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users