1 Reply Latest reply on Jul 27, 2010 7:02 PM by nbelaevski

    Part of ResponseWriter output is lost, when writing in loop

    maynard

      Hi,

       

      I am trying to develop custom renderer and I have the code:

       

      {code}

      private void encodeFixedColumnRows(FacesContext facesContext) throws IOException {
              ResponseWriter writer = facesContext.getResponseWriter();
             
              writer.startElement("table", null);
              writer.startElement("tbody", null);
              writer.writeAttribute("class", "my_class", null);
             
              log("Writing rows...");
             
              writer.startElement("tr", null);
              writer.startElement("td", null);
              writer.startElement("div", null);
              writer.write("Code 1");
              writer.endElement("div");
              writer.endElement("td");
              writer.endElement("tr");
             
              writer.startElement("tr", null);
              writer.startElement("td", null);
              writer.startElement("div", null);
              writer.write("Code 2");
              writer.endElement("div");
              writer.endElement("td");
              writer.endElement("tr");
             
              log("Writing rows completed");
             
              log("Loop...");
              for (Node node: getNodes(facesContext)) {
                  log("Writing row: " + node.getContent());
                  writer.startElement("tr", null);
                  writer.startElement("td", null);
                  writer.startElement("div", null);
                  writer.write("Code...");
                  writer.endElement("div");
                  writer.endElement("td");
                  writer.endElement("tr");
                  log("Completed");
              }
              log("Loop completed");

       

              writer.endElement("tbody");
              writer.endElement("table");
          }

      {code}

      I think, that code is OK and when I am executing it, the server logs have entries as expected - I can see that each iteration starts and ends without exception and the loop completes without exception as well and event the closing tags of table are rendered correctly on the webpage, but when I see the web-page or when I look on FireFox - view Page source, then there are only those rows that are created outside the loop (in whatever number they have been created), but there is no output from loop in web page. Why is so? Am I going against some part of some specification? It could be strange if rows cann't be created dyanamically, in fact - that is done my most of renderers. I can observer, that output is lost when it is made from nested calls as well. I am using JBoss 4.2.3 and JSF/Facelets 1.2.