This is the action method of managed bean. It prints out 1,2,3 and
throws exception. The exception is the same as the previous post

public String doAction()
{

                FacesContext facesContext = FacesUtil.getFacesContext();
                ResponseWriter writer = facesContext.getResponseWriter();

                StringWriter content = new StringWriter();
                System.out.println("1");
                ResponseWriter contentWriter = writer.cloneWithWriter(content);
                System.out.println("2");
                facesContext.setResponseWriter(contentWriter);
                System.out.println("3");


                        try
                        {
                                component3.encodeBegin(facesContext);
                                System.out.println("4");
                                component3.encodeChildren(facesContext);
                                System.out.println("5");
                                component3.encodeEnd(facesContext);
                        } catch (IOException e)
                        {
                                System.out.println("ERROR 
MESSAGE:"+e.getMessage()); // No message
print here...
                                //e.printStackTrace();
                        }


                 //reset the writer
                facesContext.setResponseWriter(writer);
                System.out.println("6");
                // get the content from StringWriter
                String htmlSource = contentWriter.toString();
                //String htmlSource = content.toString();
                System.out.println("7");
                System.out.println("doaction is called...HTML:" + htmlSource);
                return null;
        }

Reply via email to