miércoles, 6 de febrero de 2013

How download a file whit adf components


Some times when we need download a file stored in any place, for example a web service. In this case file was generated from a web service andstored in a byte array.

To download the file first need a command button or a command link. I used the comand link.

 <af:commandLink text="some text"
        id="cl1" rendered="true">
        <af:fileDownloadActionListener method="#{someMB.fileDownload}" 

         filename="#{someMB.fileName}"/>
</af:commandlink>

And in the managed bean

    public void fileDownload(FacesContext facesContext,
                                        OutputStream outputStream) {
 

        // Asume we already have a byte array
            try {
                outputStream.write(data, 0, data.length);
                outputStream.flush();
            } catch (IOException e) {
                generateErrorMessage("Error downloading file);
            }
       
    }

   
 


That is, the fileDownloadActionListener provides the mechanism to download the file.

NOTE: A limitation of the fileDownloadActionListener tag exists in Internet Explorer if the filename is multibyte, like Japanese characters. If the filename is multibyte and does not contain an ascii extension (e.g., .txt or .doc), then the filename will not display correctly in the file download box. More
 

martes, 5 de febrero de 2013

Who update my page

Today i was trying to update a web form in adf faces, it will show after as an standard portlet.

The problem was i try to update the form after the user select an item in a table into popup message. Every thing was all rigth but input text not refresh.

<af:popup id="popupDialog">
          <af:dialog title="Test Dialog" id="d2" stretchChildren="first"
                     resize="on" contentWidth="300" contentHeight="300">


I was setting the id of popup dialog (popupDialog) in partialtriggers property. It was not correct because the table's container is a dialog component, then the correct id was "d2".

Thats all, simple but take me about two hours to find solution.

Just another developer blog


Hi every body

I would like to introduce myself. Im just another person, master degree student and senior java developer.

Like in any other blog, i'll write about java languaging programming, but not complete curses only extrange cases i found along my experience. I'm a person too and I have a life, well i try, and there are a bounch of things over there and i would like share some experiences.

Finally but not less important, I'm Mexican and my writing experience is almost null, so I'm sorry for bad redaction and writing, appreciate your comments.

Tanks