This content has been marked as final.
Show 2 replies
-
1. Re: Emitting XML
bobc75 Apr 28, 2009 8:15 PM (in response to bobc75)Here's the way I ended up doing it - in case anybody's interested:
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
String query = request.getParameter("query");
HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
response.setContentType("text/xml");
Document xmlout = new Document(new Element("OneBoxResults"));
// more JDOM code here...then...
try {
PrintWriter out = response.getWriter();
XMLOutputter outputter = new XMLOutputter();
out.print(outputter.outputString(xmlout));
out.flush();
out.close();
context.responseComplete();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
and in pages.xml:
<page view-id="/gsa.xhtml">
<action execute="#{groupsGSAHandler.gsaSearch()}"/>
</page>
Note that the view-id "/gsa.xhtml" is only a place holder; there is no such file. -
2. Re: Emitting XML
pgmjsd Apr 29, 2009 5:34 AM (in response to bobc75)Have you tried using the contentType attribute of the f:view tag?
<f:view xmlns:f="http://java.sun.com/jsf/core" contentType="text/xml"> blah blah... xml with EL markup </f:view>
That would set the content type for you. We use this to make JNLP files for Java Web Start, among other things.