Hi community,
I'm using Jdev 11.1.1.7.1 and I'm following the thread https://tompeez.wordpress.com/2011/11/26/jdev11-1-2-1-0-handling-imagesfiles-in-adf-part-2/ in order to download a txt/xml file from a button which is rendered in a row of a table. In other words, I have a master-detail form where the master has a form and the detail information it's being managed by an editable table. The master-detail form looks like the following:

I added an <af:commandButton> to the last column in order to download for each detail row the blob content and when trying to download the content I'm getting the following error:
=======
=======
GetChildProcesses still processing...
Source breakpoint occurred at line 93 of XsltBean.java.
<FileDownloadActionListener> <processAction>
javax.el.ELException: java.lang.ClassCastException: oracle.jbo.domain.BlobDomain cannot be cast to oracle.adf.model.binding.DCControlBinding
at com.sun.el.parser.AstValue.invoke(Unknown Source)
at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
at org.apache.myfaces.trinidadinternal.taglib.listener.FileDownloadActionListener.processAction(FileDownloadActionListener.java:121)
at oracle.adfinternal.view.faces.event.rich.FileDownloadActionListener.processAction(FileDownloadActionListener.java:94)
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcast(UIXComponentBase.java:766)
at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:179)
at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:150)
at org.apache.myfaces.trinidad.component.UIXTable.broadcast(UIXTable.java:279)
at oracle.adf.view.rich.component.UIXTable.broadcast(UIXTable.java:145)
at oracle.adf.view.rich.component.rich.data.RichTable.broadcast(RichTable.java:428)
at oracle.adf.view.rich.component.fragment.UIXRegion.broadcast(UIXRegion.java:181)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:1100)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:446)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:211)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:128)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:324)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:460)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:163)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Caused by: java.lang.ClassCastException: oracle.jbo.domain.BlobDomain cannot be cast to oracle.adf.model.binding.DCControlBinding
at oracle.adf.model.binding.DCBindingContainer.findCtrlBinding(DCBindingContainer.java:1435)
at oracle.adf.model.binding.DCBindingContainer.getControlBinding(DCBindingContainer.java:1442)
at com.itc.view.bean.XsltBean.downloadFile(XsltBean.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
... 52 more
=======
=======
I realize the error it's pretty self-descriptive, but the fact is I'm not making that kind of cast. This is my backing bean, that it's basically the same bean that it's posted in the mentioned blog, with some minor name changes:
======
======
public class XsltBean {
_private RichCommandButton downloadXslt;_
_public XsltBean() {_
_super();_
_}_
_public void uploadFile(ValueChangeEvent valueChangeEvent) {_
_// The event give access to an Uploade dFile which contains data about the file and its content_
_UploadedFile file = (UploadedFile)valueChangeEvent.getNewValue();_
_// Get the original file name_
_String fileName = file.getFilename();_
_// get the mime type_
_//String contentType = ContentTypes.get(fileName);_
_// get the current roew from the ImagesView2Iterator via the binding_
_DCBindingContainer lBindingContainer = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();_
_DCIteratorBinding lBinding = lBindingContainer.findIteratorBinding("CfdiVO2Iterator");_
_Row newRow = lBinding.getCurrentRow();_
_// set the file name_
_//newRow.setAttribute("ImageName", fileName);_
_// create the BlobDomain and set it into the row_
_newRow.setAttribute("XsltSource", createBlobDomain(file));_
_// set the mime type_
_// newRow.setAttribute("ContentType", contentType);_
_}_
_private BlobDomain createBlobDomain(UploadedFile file) {_
_// init the internal variables_
_InputStream in = null;_
_BlobDomain blobDomain = null;_
_OutputStream out = null;_
_try {_
_// Get the input stream representing the data from the client_
_in = file.getInputStream();_
_// create the BlobDomain datatype to store the data in the db_
_blobDomain = new BlobDomain();_
_// get the outputStream for hte BlobDomain_
_out = blobDomain.getBinaryOutputStream();_
_// copy the input stream into the output stream_
_/\*_
_\* IOUtils is a class from the Apache Commons IO Package ([http://www.apache.org/](http://www.apache.org/))_
_\* Here version 2.0.1 is used_
_\* please download it directly from [http://projects.apache.org/projects/commons_io.html](http://projects.apache.org/projects/commons_io.html)_
_\*/_
_IOUtils.copy(in, out);_
_} catch (IOException e) {_
_e.printStackTrace();_
_} catch (SQLException e) {_
_e.fillInStackTrace();_
_}_
_// return the filled BlobDomain_
_return blobDomain;_
_}_
_**public void downloadFile(FacesContext facesContext, OutputStream outputStream) {**_
**_BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();_**
**_// get an ADF attributevalue from the ADF page definitions_**
**_AttributeBinding attr = (AttributeBinding) bindings.getControlBinding("CfdiVO2.XsltSource"); // \---------> THIS IS THE LINE THAT THROWS THE ERROR_**
**_if (attr == null) {_**
**_return;_**
**_}_**
**_// the value is a BlobDomain data type_**
**_BlobDomain blob = (BlobDomain) attr.getInputValue();_**
**_try { // copy hte data from the BlobDomain to the output stream_**
**_// copy hte data from the BlobDomain to the output stream_**
**_IOUtils.copy(blob.getInputStream(), outputStream);_**
**_// cloase the blob to release the recources_**
**_blob.closeInputStream();_**
**_// flush the outout stream_**
**_outputStream.flush();_**
**_} catch (IOException e) {_**
**_// handle errors_**
**_e.printStackTrace();_**
**_FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY\_ERROR, e.getMessage(), "");_**
**_FacesContext.getCurrentInstance().addMessage(null, msg);_**
**_}_**
**_}_**
_public void setDownloadXslt(RichCommandButton downloadXslt) {_
_this.downloadXslt = downloadXslt;_
_}_
_public RichCommandButton getDownloadXslt() {_
_return downloadXslt;_
_}_
}
======
======
I debugged the code in order to check if the Binding it's working correctly, and for some reason the Binding it's not working:

The following it's the bindings for the page I'm working with:
===========
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
_xmlns:af="[http://xmlns.oracle.com/adf/faces/rich](http://xmlns.oracle.com/adf/faces/rich)"_
_xmlns:f="[http://java.sun.com/jsf/core](http://java.sun.com/jsf/core)">_
<af:panelSplitter id="ps1" orientation="vertical">
_\<f:facet name="first">_
_\<af:panelBox text="PAC Administration" id="pb1">_
_\<f:facet name="toolbar">_
_\<af:toolbar id="t1">_
_\<af:commandButton text="Save" id="cb1" action="save"/>_
_\<af:commandButton text="Cancel" id="cb2" action="cancel"/>_
_\</af:toolbar>_
_\</f:facet>_
_\<af:panelFormLayout id="pfl1">_
_\<af:inputText value="#{bindings.PacId.inputValue}"_
_label="#{bindings.PacId.hints.label}"_
_required="#{bindings.PacId.hints.mandatory}"_
_columns="#{bindings.PacId.hints.displayWidth}"_
_maximumLength="#{bindings.PacId.hints.precision}"_
_shortDesc="#{bindings.PacId.hints.tooltip}" id="it3">_
_\<f:validator binding="#{bindings.PacId.validator}"/>_
_\<af:convertNumber groupingUsed="false"_
_pattern="#{bindings.PacId.format}"/>_
_\</af:inputText>_
_\<af:inputText value="#{bindings.Name.inputValue}"_
_label="#{bindings.Name.hints.label}"_
_required="#{bindings.Name.hints.mandatory}"_
_columns="#{bindings.Name.hints.displayWidth}"_
_maximumLength="#{bindings.Name.hints.precision}"_
_shortDesc="#{bindings.Name.hints.tooltip}" id="it4">_
_\<f:validator binding="#{bindings.Name.validator}"/>_
_\</af:inputText>_
_\<af:inputText value="#{bindings.Endpoint.inputValue}"_
_label="#{bindings.Endpoint.hints.label}"_
_required="#{bindings.Endpoint.hints.mandatory}"_
_columns="#{bindings.Endpoint.hints.displayWidth}"_
_maximumLength="#{bindings.Endpoint.hints.precision}"_
_shortDesc="#{bindings.Endpoint.hints.tooltip}" id="it1">_
_\<f:validator binding="#{bindings.Endpoint.validator}"/>_
_\</af:inputText>_
_\<af:selectOneChoice value="#{bindings.Status1.inputValue}"_
_label="#{bindings.Status1.label}"_
_required="#{bindings.Status1.hints.mandatory}"_
_shortDesc="#{bindings.Status1.hints.tooltip}"_
_id="soc2">_
_\<f:selectItems value="#{bindings.Status1.items}" id="si2"/>_
_\</af:selectOneChoice>_
_\</af:panelFormLayout>_
_\</af:panelBox>_
_\</f:facet>_
_\<f:facet name="second">_
_\<af:panelBox text="CFDI Versions" id="pb2">_
_\<f:facet name="toolbar">_
_\<af:toolbar id="t3">_
_\<af:commandButton actionListener="#{bindings.CreateInsert.execute}"_
_text="Add CFDI Version"_
_disabled="#{!bindings.CreateInsert.enabled}"_
_id="cb3"/>_
_\<af:commandButton actionListener="#{bindings.Delete.execute}"_
_text="Delete CFDI Version"_
_disabled="#{!bindings.Delete.enabled}" id="cb4"/>_
_\</af:toolbar>_
_\</f:facet>_
_\<af:table value="#{bindings.CfdiVO2.collectionModel}" var="row"_
_rows="#{bindings.CfdiVO2.rangeSize}"_
_emptyText="#{bindings.CfdiVO2.viewable ? 'No data to display.' : 'Access Denied.'}"_
_fetchSize="#{bindings.CfdiVO2.rangeSize}"_
_rowBandingInterval="0"_
_filterModel="#{bindings.CfdiVO2Query.queryDescriptor}"_
_queryListener="#{bindings.CfdiVO2Query.processQuery}"_
_filterVisible="true" varStatus="vs"_
_selectedRowKeys="#{bindings.CfdiVO2.collectionModel.selectedRow}"_
_selectionListener="#{bindings.CfdiVO2.collectionModel.makeCurrent}"_
_rowSelection="single" id="t2" partialTriggers="::cb3 ::cb4"_
_columnStretching="last">_
_\<af:column sortProperty="#{bindings.CfdiVO2.hints.CfdiId.name}"_
_filterable="true" sortable="true"_
_headerText="#{bindings.CfdiVO2.hints.CfdiId.label}"_
_id="c5">_
_\<af:inputText value="#{row.bindings.CfdiId.inputValue}"_
_label="#{bindings.CfdiVO2.hints.CfdiId.label}"_
_required="#{bindings.CfdiVO2.hints.CfdiId.mandatory}"_
_columns="#{bindings.CfdiVO2.hints.CfdiId.displayWidth}"_
_maximumLength="#{bindings.CfdiVO2.hints.CfdiId.precision}"_
_shortDesc="#{bindings.CfdiVO2.hints.CfdiId.tooltip}"_
_id="it5" readOnly="true">_
_\<f:validator binding="#{row.bindings.CfdiId.validator}"/>_
_\<af:convertNumber groupingUsed="false"_
_pattern="#{bindings.CfdiVO2.hints.CfdiId.format}"/>_
_\</af:inputText>_
_\</af:column>_
_\<af:column sortProperty="#{bindings.CfdiVO2.hints.Status.name}"_
_filterable="true" sortable="true"_
_headerText="#{bindings.CfdiVO2.hints.Status.label}"_
_id="c2">_
_\<af:selectOneChoice label="#{row.bindings.Status.label}" id="soc1"_
_value="#{row.bindings.Status.inputValue}">_
_\<f:selectItems value="#{row.bindings.Status.items}" id="si1"/>_
_\</af:selectOneChoice>_
_\</af:column>_
_\<af:column sortProperty="#{bindings.CfdiVO2.hints.Name.name}"_
_filterable="true" sortable="true"_
_headerText="#{bindings.CfdiVO2.hints.Name.label}" id="c3">_
_\<af:inputText value="#{row.bindings.Name.inputValue}"_
_label="#{bindings.CfdiVO2.hints.Name.label}"_
_required="#{bindings.CfdiVO2.hints.Name.mandatory}"_
_columns="#{bindings.CfdiVO2.hints.Name.displayWidth}"_
_maximumLength="#{bindings.CfdiVO2.hints.Name.precision}"_
_shortDesc="#{bindings.CfdiVO2.hints.Name.tooltip}"_
_id="it10">_
_\<f:validator binding="#{row.bindings.Name.validator}"/>_
_\</af:inputText>_
_\</af:column>_
_\<af:column sortProperty="#{bindings.CfdiVO2.hints.Description.name}"_
_filterable="true" sortable="true"_
_headerText="#{bindings.CfdiVO2.hints.Description.label}"_
_id="c4">_
_\<af:inputText value="#{row.bindings.Description.inputValue}"_
_label="#{bindings.CfdiVO2.hints.Description.label}"_
_required="#{bindings.CfdiVO2.hints.Description.mandatory}"_
_columns="#{bindings.CfdiVO2.hints.Description.displayWidth}"_
_maximumLength="#{bindings.CfdiVO2.hints.Description.precision}"_
_shortDesc="#{bindings.CfdiVO2.hints.Description.tooltip}"_
_id="it6">_
_\<f:validator binding="#{row.bindings.Description.validator}"/>_
_\</af:inputText>_
_\</af:column>_
_\<af:column sortProperty="#{bindings.CfdiVO2.hints.XsltSource.name}"_
_sortable="true"_
_headerText="#{bindings.CfdiVO2.hints.XsltSource.label}"_
_id="c6">_
_\<af:commandButton text="Download file" id="cb5"_
_binding="#{XsltBean.downloadXslt}">_
_\<af:fileDownloadActionListener method="#{XsltBean.downloadFile}"/>_
_\</af:commandButton>_
_\<af:inputFile label="Label 1" id="if1"_
_valueChangeListener="#{XsltBean.uploadFile}"_
_autoSubmit="false"/>_
_\</af:column>_
_\</af:table>_
_\</af:panelBox>_
_\</f:facet>_
</af:panelSplitter>
<!--oracle-jdev-comment:preferred-managed-bean-name:XsltBean-->
</jsp:root>
===========
And finally, this is how the button and its listener are configured:
======
======
<af:commandButton text="Download file" id="cb5"
_binding="#{XsltBean.downloadXslt}">_
_\<af:fileDownloadActionListener method="#{XsltBean.downloadFile}"/>_
_\</af:commandButton>_
======
======
Any ideas?
Thanks in advance.
Juan