Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Download Image not working

aJohnyApr 6 2015 — edited Apr 6 2015

HI,

Jdev 12.1.3

I have a table which stores blob object.

1.JPG

I am using a fileDownloadActionListener for downloading the file.

<af:column headerText="Download" id="c3">

                        \<af:link text="#{row.FileName}" id="l1">

                            \<af:fileDownloadActionListener filename="#{row.FileName}"

                                                           method="#{downloadBean.downloadBlobFile}"

                                                           contentType="#{row.MimeType}"/>

                        \</af:link>

                    \</af:column>

Code to download the file:

public void downloadBlobFile(FacesContext facesContext, OutputStream outputStream)

{

    BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();

    AttributeBinding attr = (AttributeBinding) bindings.getControlBinding("Image");

    if (attr != null)

    {

        BlobDomain blob = (BlobDomain) attr.getInputValue();

        try

        {   // copy hte data from the blobDomain to the output stream

            IOUtils.copy(blob.getInputStream(), outputStream);

            blob.closeInputStream();

            outputStream.flush();

        }

        catch (IOException e)

        {

            // handle errors

            e.printStackTrace();

            FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY\_ERROR, e.getMessage(), "");

            FacesContext.getCurrentInstance().addMessage(null, msg);

        }

    }

}

AttributeBinding attr = (AttributeBinding) bindings.getControlBinding("Image");

The above line is returning null;

This is working fine in my other project. But not able to find out what is missing.

Cheers

AJ

This post has been answered by Cvele_new_account on Apr 6 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 4 2015
Added on Apr 6 2015
12 comments
1,767 views