Hello friend,
is possible dhtmlXGridObject catch a XML return through Action Struts (like a response.getWriter() - Java)?
example:
my page (jsp):
…
…
My action Struts:
…
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.XMLOutputter;
…
// Important: I�m using Jdom to generate XML
public ActionForward buildXMLGrid(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
try{
List nodes = new ArrayList();
// Important: I�m using Jdom to generate XML
Element rows = new Element(“rows”);
Element row = new Element(“row”);
Element cell = new Element(“cell”);
for (Integer a = 0 ; a <=3 ; a++){
nodes.add(new Element(“cell”).setText(a.toString()));
}
cell.setChildren(nodes);
row.addContent(cell);
rows.addContent(row);
Document doc = new Document();
doc.setRootElement(rows);
//Imptrimindo o XML
XMLOutputter xout = new XMLOutputter(" ", true);
xout.setEncoding(“iso-8859-1”);
xout.output(doc, System.out);
response.setContentType(“text/xml; charset=iso-8859-1”);
response.setHeader(“Cache-Control”, “no-store, max-age=0, no-cache, must-revalidate”);
response.addHeader(“Cache-Control”, “post-check=0, pre-check=0”);
response.setHeader(“Pragma”, “no-cache”);
PrintWriter out = response.getWriter();
out.print(xout);
out.close();
return null;
} catch (Exception e){
return null;
}
…
is possible dhtmlXGridObject catch a XML return through Action Struts (like a response.getWriter() - Java)?
Yes, it possible , while response contains valid XML data and sent with valid headers - it is not difference is data as static XML file or generated by any kind of server side script.
As far as I can see provided code is correct.
If , by any chance, you still get “Incorrect XML” message - please check
dhtmlx.com/docs/products/dhtmlxG … rt_comprob