You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ángel Miralles Arévalo <an...@yahoo.es> on 2011/02/01 12:43:23 UTC

OPEN DOCUMENT NEW WINDOW

Hey, I'm trying to open a pdf in a new window. Anyone with some experience?

My jsp code is:
                
 <h:commandLink value="" actionListener="#{docsProyectoVO.descargaDoc}" 
immediate="true">
          <h:graphicImage url="#{rsc.btn_pdf}"  styleClass="border0"/>
          <f:param value="#{documento.idProyecto}" name="idProyecto" />
          <f:param value="#{documento.idDocumento}" name="idDocumento" />
 </h:commandLink>

The managed bean:

public void descargaDoc (ActionEvent event){
        
        try{
            String idP = (String) 
getApplication().createValueBinding("#{param.idProyecto}").getValue(getFacesContext());

            String idD = (String) 
getApplication().createValueBinding("#{param.idDocumento}").getValue(getFacesContext());

            
            if (!this.lstDocumentos.isEmpty() && idP != null && 
!idP.equalsIgnoreCase("")) {
                // Obtenemos fichero de bbdd
                DocumentoDTO d = 
getIProyectoSvc().obtenerDocumento(Long.parseLong(idD));    

                
                if (d != null) {
                    generaDoc(d.getDatosDocumento(), d.getStrNombre(), 
d.getStrMime());
                }
            }
        }catch(Exception e){
            e.printStackTrace();
        }
    }

public static void downloadFile(HttpServletResponse response, byte[] bytes, 
String fileName, String fileType, boolean attachment) throws IOException {
        // Prepare stream.
        BufferedOutputStream output = null;

        try {
            // Prepare.
            int contentLength = bytes.length;
            String disposition = "attachment";

            // If content type is unknown, then set the default value.
            // For all content types, see:
            // http://www.w3schools.com/media/media_mimeref.asp
            if (fileType == null) {
                fileType = "application/octet-stream";
            }

            // Init servlet response.
            response.setContentLength(contentLength);
            response.setContentType(fileType);
            response.setHeader("Content-disposition", disposition + "; 
filename=\"" + fileName + "\"");
            //response.addHeader("Content-Disposition", 
"inline;filename="+fileName);
            output = new BufferedOutputStream(response.getOutputStream());

            output.write(bytes);

            // Finalize task.
            output.flush();
        } finally {
            // Gently close stream.
            if (output != null) {
                try {
                    output.close();
                } catch (IOException e) {
                    e.printStackTrace();
                    // This is a serious error. Do more than just printing a
                    // trace.
                }
            }
        }
   
The first problem is h:commandLink without immediate='true' does't get de 
ActionListener. When immediate='true' a get the documet open at the same page... 
I am navigating.

My configuration:

	* jsf-facelets
	* myfaces 3.2.2
	* jboss 4.2
Thanks for all.... ;)               



      

Re: OPEN DOCUMENT NEW WINDOW

Posted by Ángel Miralles Arévalo <an...@yahoo.es>.
Hey guys, I've done with a servlet just Walter said and it works perfect. The 
only problematic thing was 


response.setHeader("Content-disposition", disposition + " filename=\"" + 
fileName + "\"");

with: 

String disposition='attachment'

Thanks    ;)




________________________________
De: Mike Kienenberger <mk...@gmail.com>
Para: MyFaces Discussion <us...@myfaces.apache.org>
Enviado: mar,1 febrero, 2011 21:43
Asunto: Re: OPEN DOCUMENT NEW WINDOW

We were not able to find easy ways to do this.

We came up with two ways, neither of which are perfect.

1) Write a jsp page which is passed a static url to the PDF object.
This is probably similar to the servlet solution that Walter
suggested.  Doesn't work well with dynamically-generated pdfs unless
you're ok with a specific url always returning a specific pdf file for
all users.

2) Use frames with onload.  Here's a simplified version of what we do for that.


========viewPdf.xhtml=======
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <body>
<!-- Text above this line is ignored -->
    <ui:composition
     template="/pages/include/template.xhtml"
     xmlns="http://www.w3.org/1999/xhtml"
     xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:jstl="http://java.sun.com/jsp/jstl/functions"
     xmlns:h="http://java.sun.com/jsf/html"
     xmlns:f="http://java.sun.com/jsf/core">


      <ui:define  name="body">

        <iframe name="PdfFrame" src="viewPdfFrame.xhtml"  class="pdfIframe" >
            <h3>Loading printable pdf. Please wait....</h3>
        </iframe>

      </ui:define>
    </ui:composition>

<!-- Text below this line is ignored -->
  </body>
</html>
============================

-------------------viewPdf-frame.xhtml--------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<!-- Text above this line is ignored -->
    <ui:composition
     xmlns="http://www.w3.org/1999/xhtml"
     xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:jstl="http://java.sun.com/jsp/jstl/functions"
     xmlns:h="http://java.sun.com/jsf/html"
     xmlns:f="http://java.sun.com/jsf/core">

<html>
    <head>
        <title>
            printable pdf
        </title>
    </head>
    <body>
        <h:form id="masterForm">
                <h:commandButton
                    id="executeOnloadButton"
                    action="#{page.downloadPdfInline}"
                    value="show pdf inline"
                    style="display: none"/>
        </h:form>

        <h3>Loading printable pdf. Please wait....</h3>
        
        <script language="JavaScript" type="text/javascript">
            //<![CDATA[
            
window.onload=document.getElementById('masterForm:executeOnloadButton').click();
            //]]>
        </script>
    
    </body>
</html>

    </ui:composition>
<!-- Text below this line is ignored -->
-------------------------------------------------------------

#{page.downloadPdfInline} calls
        return downloadPdf(ResponseMethod.INLINE);

The source code looks like this, but has been simplified and sanitized
(not sure if it'll compile, and you'd need better error handling)

Note that navigation rule "viewPdfError" refers to an xhtml page which
contains only an <h:messages> component.

I can't remember why this opens the pdf in a new window, but it does
work.  I hope I haven't left off some bit of relevent code.
Actually, I wonder if someone has changed the code since I last looked
at it.   It's opening it for me in an external viewer right now rather
than as a new tab in my web browser.  Maybe it's a configuration issue
in my web browser.   In any case, the basic idea of using a frame will
work -- it should get you started on your way to doing what you need.

For any other lurkers, if you don't need a new window,
downloadPdf(ResponseMethod responseMethod) as a regular action target
does everything you need with no special xhtml code.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=        


        
    private String downloadPdf(ResponseMethod responseMethod) throws
DataAccessException
    {
        byte[] buffer;
        try {
            buffer = generatePDF();
        } catch (PdfGenerationException e) {
            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_ERROR,
                            "Error generating pdf.", e)
                    );
            return "viewPdfError";
        }
        InputStream dataInputStream = new ByteArrayInputStream(buffer);
        int dataLength = buffer.length;
        String dataContentType = "application/pdf";
        String filename = "nameOfPdfHere.pdf";
        
        try {
            exportFileAction(dataInputStream, dataLength, dataContentType,
responseMethod, filename);
        } catch (IOException e) {
            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_ERROR,
                            "Error displaying pdf.", e)
                    );
            return "viewPdfError";
        }
        return null;
    }

    protected enum ResponseMethod {
        INLINE ("inline"),
        ATTACHMENT ("attachment");
        
        private final String contentDispositionString;
        ResponseMethod (String contentDispositionString) {
            this.contentDispositionString = contentDispositionString;
        }
        
        public String getContentDispositionString() {
            return contentDispositionString;
        }
    }

    protected void exportFileAction(InputStream dataInputStream, int
dataLength, String dataContentType, ResponseMethod responseMethod,
String filename)
        throws IOException, AbortProcessingException
    {
        if (null == dataInputStream)  throw new
AbortProcessingException("dataInputStream is null");

        FacesContext facesContext = FacesContext.getCurrentInstance();

        ExternalContext externalContext = facesContext.getExternalContext();

        // Note: this currently makes it unusable for portlets
        HttpServletResponse response =
(HttpServletResponse)externalContext.getResponse();
        
        OutputStream responseStream = response.getOutputStream();
        if (null == responseStream)  throw new
AbortProcessingException("responseStream is null");

        response.setContentType(dataContentType);

        // private cache
        response.addHeader("Cache-Control", "private");

        response.setHeader("Content-Disposition",
responseMethod.getContentDispositionString() + ";filename=\"" +
filename + "\"");
        response.setContentLength(dataLength);

        // See fastChannelCopy[1]
        final ReadableByteChannel inputChannel =
Channels.newChannel(dataInputStream);
        final WritableByteChannel outputChannel =
Channels.newChannel(responseStream);
        // copy the channels
        fastChannelCopy(inputChannel, outputChannel);
        inputChannel.close();
        outputChannel.close();

        response.flushBuffer();

        facesContext.responseComplete();
    }

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=        


2011/2/1 Ángel Miralles Arévalo <an...@yahoo.es>:
> Hey, I'm trying to open a pdf in a new window. Anyone with some experience?
>
> My jsp code is:
>
>  <h:commandLink value="" actionListener="#{docsProyectoVO.descargaDoc}"
> immediate="true">
>          <h:graphicImage url="#{rsc.btn_pdf}"  styleClass="border0"/>
>          <f:param value="#{documento.idProyecto}" name="idProyecto" />
>          <f:param value="#{documento.idDocumento}" name="idDocumento" />
>  </h:commandLink>
>
> The managed bean:
>
> public void descargaDoc (ActionEvent event){
>
>        try{
>            String idP = (String)
>getApplication().createValueBinding("#{param.idProyecto}").getValue(getFacesContext());
>;
>
>            String idD = (String)
>getApplication().createValueBinding("#{param.idDocumento}").getValue(getFacesContext());
>;
>
>
>            if (!this.lstDocumentos.isEmpty() && idP != null &&
> !idP.equalsIgnoreCase("")) {
>                // Obtenemos fichero de bbdd
>                DocumentoDTO d =
> getIProyectoSvc().obtenerDocumento(Long.parseLong(idD));
>
>
>                if (d != null) {
>                    generaDoc(d.getDatosDocumento(), d.getStrNombre(),
> d.getStrMime());
>                }
>            }
>        }catch(Exception e){
>            e.printStackTrace();
>        }
>    }
>
> public static void downloadFile(HttpServletResponse response, byte[] bytes,
> String fileName, String fileType, boolean attachment) throws IOException {
>        // Prepare stream.
>        BufferedOutputStream output = null;
>
>        try {
>            // Prepare.
>            int contentLength = bytes.length;
>            String disposition = "attachment";
>
>            // If content type is unknown, then set the default value.
>            // For all content types, see:
>            // http://www.w3schools.com/media/media_mimeref.asp
>            if (fileType == null) {
>                fileType = "application/octet-stream";
>            }
>
>            // Init servlet response.
>            response.setContentLength(contentLength);
>            response.setContentType(fileType);
>            response.setHeader("Content-disposition", disposition + ";
> filename=\"" + fileName + "\"");
>            //response.addHeader("Content-Disposition",
> "inline;filename="+fileName);
>            output = new BufferedOutputStream(response.getOutputStream());
>
>            output.write(bytes);
>
>            // Finalize task.
>            output.flush();
>        } finally {
>            // Gently close stream.
>            if (output != null) {
>                try {
>                    output.close();
>                } catch (IOException e) {
>                    e.printStackTrace();
>                    // This is a serious error. Do more than just printing a
>                    // trace.
>                }
>            }
>        }
>
> The first problem is h:commandLink without immediate='true' does't get de
> ActionListener. When immediate='true' a get the documet open at the same 
>page...
> I am navigating.
>
> My configuration:
>
>        * jsf-facelets
>        * myfaces 3.2.2
>        * jboss 4.2
> Thanks for all.... ;)
>
>
>
>



      

Re: OPEN DOCUMENT NEW WINDOW

Posted by Mike Kienenberger <mk...@gmail.com>.
We were not able to find easy ways to do this.

We came up with two ways, neither of which are perfect.

1) Write a jsp page which is passed a static url to the PDF object.
This is probably similar to the servlet solution that Walter
suggested.  Doesn't work well with dynamically-generated pdfs unless
you're ok with a specific url always returning a specific pdf file for
all users.

2) Use frames with onload.  Here's a simplified version of what we do for that.


========viewPdf.xhtml=======
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <body>
<!-- Text above this line is ignored -->
    <ui:composition
     template="/pages/include/template.xhtml"
     xmlns="http://www.w3.org/1999/xhtml"
     xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:jstl="http://java.sun.com/jsp/jstl/functions"
     xmlns:h="http://java.sun.com/jsf/html"
     xmlns:f="http://java.sun.com/jsf/core">


      <ui:define  name="body">

		<iframe name="PdfFrame" src="viewPdfFrame.xhtml"  class="pdfIframe" >
			<h3>Loading printable pdf. Please wait....</h3>
		</iframe>

      </ui:define>
    </ui:composition>

<!-- Text below this line is ignored -->
  </body>
</html>
============================

-------------------viewPdf-frame.xhtml--------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<!-- Text above this line is ignored -->
    <ui:composition
     xmlns="http://www.w3.org/1999/xhtml"
     xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:jstl="http://java.sun.com/jsp/jstl/functions"
     xmlns:h="http://java.sun.com/jsf/html"
     xmlns:f="http://java.sun.com/jsf/core">

<html>
	<head>
		<title>
			printable pdf
		</title>
	</head>
	<body>
		<h:form id="masterForm">
				<h:commandButton
					id="executeOnloadButton"
					action="#{page.downloadPdfInline}"
					value="show pdf inline"
					style="display: none"/>
		</h:form>

		<h3>Loading printable pdf. Please wait....</h3>
		
    	<script language="JavaScript" type="text/javascript">
			//<![CDATA[
			window.onload=document.getElementById('masterForm:executeOnloadButton').click();
			//]]>
    	</script>
	
	</body>
</html>

    </ui:composition>
<!-- Text below this line is ignored -->
-------------------------------------------------------------

#{page.downloadPdfInline} calls
    	return downloadPdf(ResponseMethod.INLINE);

The source code looks like this, but has been simplified and sanitized
(not sure if it'll compile, and you'd need better error handling)

Note that navigation rule "viewPdfError" refers to an xhtml page which
contains only an <h:messages> component.

I can't remember why this opens the pdf in a new window, but it does
work.  I hope I haven't left off some bit of relevent code.
Actually, I wonder if someone has changed the code since I last looked
at it.   It's opening it for me in an external viewer right now rather
than as a new tab in my web browser.  Maybe it's a configuration issue
in my web browser.   In any case, the basic idea of using a frame will
work -- it should get you started on your way to doing what you need.

For any other lurkers, if you don't need a new window,
downloadPdf(ResponseMethod responseMethod) as a regular action target
does everything you need with no special xhtml code.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=    	


    	
	private String downloadPdf(ResponseMethod responseMethod) throws
DataAccessException
    {
		byte[] buffer;
    	try {
            buffer = generatePDF();
		} catch (PdfGenerationException e) {
            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_ERROR,
                            "Error generating pdf.", e)
                    );
            return "viewPdfError";
		}
    	InputStream dataInputStream = new ByteArrayInputStream(buffer);
    	int dataLength = buffer.length;
    	String dataContentType = "application/pdf";
    	String filename = "nameOfPdfHere.pdf";
    	
    	try {
    		exportFileAction(dataInputStream, dataLength, dataContentType,
responseMethod, filename);
		} catch (IOException e) {
            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_ERROR,
                            "Error displaying pdf.", e)
                    );
            return "viewPdfError";
		}
    	return null;
    }

    protected enum ResponseMethod {
    	INLINE ("inline"),
    	ATTACHMENT ("attachment");
    	
    	private final String contentDispositionString;
		ResponseMethod (String contentDispositionString) {
    		this.contentDispositionString = contentDispositionString;
    	}
    	
    	public String getContentDispositionString() {
			return contentDispositionString;
		}
    }

    protected void exportFileAction(InputStream dataInputStream, int
dataLength, String dataContentType, ResponseMethod responseMethod,
String filename)
    	throws IOException, AbortProcessingException
    {
        if (null == dataInputStream)  throw new
AbortProcessingException("dataInputStream is null");

        FacesContext facesContext = FacesContext.getCurrentInstance();

        ExternalContext externalContext = facesContext.getExternalContext();

        // Note: this currently makes it unusable for portlets
        HttpServletResponse response =
(HttpServletResponse)externalContext.getResponse();
		
        OutputStream responseStream = response.getOutputStream();
        if (null == responseStream)  throw new
AbortProcessingException("responseStream is null");

        response.setContentType(dataContentType);

        // private cache
        response.addHeader("Cache-Control", "private");

        response.setHeader("Content-Disposition",
responseMethod.getContentDispositionString() + ";filename=\"" +
filename + "\"");
        response.setContentLength(dataLength);

        // See fastChannelCopy[1]
    	final ReadableByteChannel inputChannel =
Channels.newChannel(dataInputStream);
    	final WritableByteChannel outputChannel =
Channels.newChannel(responseStream);
    	// copy the channels
    	fastChannelCopy(inputChannel, outputChannel);
    	inputChannel.close();
    	outputChannel.close();

        response.flushBuffer();

        facesContext.responseComplete();
    }

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=    	


2011/2/1 Ángel Miralles Arévalo <an...@yahoo.es>:
> Hey, I'm trying to open a pdf in a new window. Anyone with some experience?
>
> My jsp code is:
>
>  <h:commandLink value="" actionListener="#{docsProyectoVO.descargaDoc}"
> immediate="true">
>          <h:graphicImage url="#{rsc.btn_pdf}"  styleClass="border0"/>
>          <f:param value="#{documento.idProyecto}" name="idProyecto" />
>          <f:param value="#{documento.idDocumento}" name="idDocumento" />
>  </h:commandLink>
>
> The managed bean:
>
> public void descargaDoc (ActionEvent event){
>
>        try{
>            String idP = (String)
> getApplication().createValueBinding("#{param.idProyecto}").getValue(getFacesContext());
>
>            String idD = (String)
> getApplication().createValueBinding("#{param.idDocumento}").getValue(getFacesContext());
>
>
>            if (!this.lstDocumentos.isEmpty() && idP != null &&
> !idP.equalsIgnoreCase("")) {
>                // Obtenemos fichero de bbdd
>                DocumentoDTO d =
> getIProyectoSvc().obtenerDocumento(Long.parseLong(idD));
>
>
>                if (d != null) {
>                    generaDoc(d.getDatosDocumento(), d.getStrNombre(),
> d.getStrMime());
>                }
>            }
>        }catch(Exception e){
>            e.printStackTrace();
>        }
>    }
>
> public static void downloadFile(HttpServletResponse response, byte[] bytes,
> String fileName, String fileType, boolean attachment) throws IOException {
>        // Prepare stream.
>        BufferedOutputStream output = null;
>
>        try {
>            // Prepare.
>            int contentLength = bytes.length;
>            String disposition = "attachment";
>
>            // If content type is unknown, then set the default value.
>            // For all content types, see:
>            // http://www.w3schools.com/media/media_mimeref.asp
>            if (fileType == null) {
>                fileType = "application/octet-stream";
>            }
>
>            // Init servlet response.
>            response.setContentLength(contentLength);
>            response.setContentType(fileType);
>            response.setHeader("Content-disposition", disposition + ";
> filename=\"" + fileName + "\"");
>            //response.addHeader("Content-Disposition",
> "inline;filename="+fileName);
>            output = new BufferedOutputStream(response.getOutputStream());
>
>            output.write(bytes);
>
>            // Finalize task.
>            output.flush();
>        } finally {
>            // Gently close stream.
>            if (output != null) {
>                try {
>                    output.close();
>                } catch (IOException e) {
>                    e.printStackTrace();
>                    // This is a serious error. Do more than just printing a
>                    // trace.
>                }
>            }
>        }
>
> The first problem is h:commandLink without immediate='true' does't get de
> ActionListener. When immediate='true' a get the documet open at the same page...
> I am navigating.
>
> My configuration:
>
>        * jsf-facelets
>        * myfaces 3.2.2
>        * jboss 4.2
> Thanks for all.... ;)
>
>
>
>

Re: OPEN DOCUMENT NEW WINDOW

Posted by Walter Mourão <wa...@gmail.com>.
1 - create a servlet to return the pdf
2 - using javascript open the new window with a <object/> element pointing
to the servlet


Walter Mourão
http://waltermourao.com.br
http://arcadian.com.br
http://oriens.com.br



2011/2/1 Ángel Miralles Arévalo <an...@yahoo.es>

> Hey, I'm trying to open a pdf in a new window. Anyone with some experience?
>
> My jsp code is:
>
>  <h:commandLink value="" actionListener="#{docsProyectoVO.descargaDoc}"
> immediate="true">
>          <h:graphicImage url="#{rsc.btn_pdf}"  styleClass="border0"/>
>          <f:param value="#{documento.idProyecto}" name="idProyecto" />
>          <f:param value="#{documento.idDocumento}" name="idDocumento" />
>  </h:commandLink>
>
> The managed bean:
>
> public void descargaDoc (ActionEvent event){
>
>        try{
>            String idP = (String)
>
> getApplication().createValueBinding("#{param.idProyecto}").getValue(getFacesContext());
>
>            String idD = (String)
>
> getApplication().createValueBinding("#{param.idDocumento}").getValue(getFacesContext());
>
>
>            if (!this.lstDocumentos.isEmpty() && idP != null &&
> !idP.equalsIgnoreCase("")) {
>                // Obtenemos fichero de bbdd
>                DocumentoDTO d =
> getIProyectoSvc().obtenerDocumento(Long.parseLong(idD));
>
>
>                if (d != null) {
>                    generaDoc(d.getDatosDocumento(), d.getStrNombre(),
> d.getStrMime());
>                }
>            }
>        }catch(Exception e){
>            e.printStackTrace();
>        }
>    }
>
> public static void downloadFile(HttpServletResponse response, byte[] bytes,
> String fileName, String fileType, boolean attachment) throws IOException {
>        // Prepare stream.
>        BufferedOutputStream output = null;
>
>        try {
>            // Prepare.
>            int contentLength = bytes.length;
>            String disposition = "attachment";
>
>            // If content type is unknown, then set the default value.
>            // For all content types, see:
>            // http://www.w3schools.com/media/media_mimeref.asp
>            if (fileType == null) {
>                fileType = "application/octet-stream";
>            }
>
>            // Init servlet response.
>            response.setContentLength(contentLength);
>            response.setContentType(fileType);
>            response.setHeader("Content-disposition", disposition + ";
> filename=\"" + fileName + "\"");
>            //response.addHeader("Content-Disposition",
> "inline;filename="+fileName);
>            output = new BufferedOutputStream(response.getOutputStream());
>
>            output.write(bytes);
>
>            // Finalize task.
>            output.flush();
>        } finally {
>            // Gently close stream.
>            if (output != null) {
>                try {
>                    output.close();
>                } catch (IOException e) {
>                    e.printStackTrace();
>                    // This is a serious error. Do more than just printing a
>                    // trace.
>                }
>            }
>        }
>
> The first problem is h:commandLink without immediate='true' does't get de
> ActionListener. When immediate='true' a get the documet open at the same
> page...
> I am navigating.
>
> My configuration:
>
>        * jsf-facelets
>        * myfaces 3.2.2
>        * jboss 4.2
> Thanks for all.... ;)
>
>
>
>