Making a download or an export was never so easy as in JDeveloper 11g just follow these steps and you have own a xml export file of a rich table or any viewobject used in the page definition. For this blog entry I will use ADF BC which supports writexml and the fileDownloadActionListener jsf component which handles the download of the file.
first we drag a new toolbar button to the panel collection of a rich table.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDl6w5d4VPu6IwJeBpphMU4tVhHMMcz4OhU-60owLZuGKoBkjXhAWJBX_ezIqoIsBg5oleYvBhDTKMmgpG6cSjvuyUUuM7o7_cn1HlBuFDhvfjPnCnn3AqoGJASvkw9o6TPDq3hSYYcI4/s400/exportxml_1.png)
drag the file download action listener from the component palette to the new toolbar button
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCbsiapVaH1h6vK3bNH9iDuhdPZG-drt6cEIximWTLy47Dhif7QXXqhiqmdtn6khcPc4w-Ie_YTqHcknbV2h3zxEd1M57sCyFMgziHoEciQ36CCvwkBwfqynl6ufFVz8aGW_cQec3bGe8/s400/exportxml_2.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtiR0F3apVykMECaCz2X6Y8CSV9VaR_xobBNCIpHKIO1sKmZgyTaHywRNy63_JlsXuUwiye7wcgPXMAVSvOnhWulJgaMkSbukaxHFkpxikweHJonZKa5QoQnPQipj1l81slEm-zo_I3hc/s400/exportxml_3.png)
Select the edit menu item of the method property so we create an new backing bean.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgx4TcJGhheusYkofAwAZfnRcJ3lMqE2L1KXH1Wrr9u-5fXsyn-W9wxrsf-U5GaSKQbQU_yGARz3TeQjNKJ7yn8kUeUxHgUxrAvdfwQPSXt-P2iH9wALGtQ2X-itbh-FkGxCufMHXPJnF0/s400/exportxml_4.png)
Press the New button to create a new backing bean
Now we can create a new method in this bean.
and here is method code and we are finished
package nl.ordina.richtable.view.beans;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import javax.faces.context.FacesContext;
import nl.ordina.richtable.model.dataaccess.EmployeesViewImpl;
import oracle.adf.model.BindingContext;
import oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding;
import oracle.binding.BindingContainer;
import oracle.jbo.XMLInterface;
import oracle.xml.parser.v2.XMLNode;
public class ExportBean {
public ExportBean() {
}
public void exportXml(FacesContext facesContext,
OutputStream outputStream) {
// Add event code here...
BindingContainer bc = BindingContext.getCurrent().getCurrentBindingsEntry();
List controlBindings = bc.getControlBindings();
FacesCtrlHierBinding hierBinding = (FacesCtrlHierBinding) bc.getControlBinding("EmployeesView");
EmployeesViewImpl employees = (EmployeesViewImpl) hierBinding.getViewObject();
try {
((XMLNode)(employees.writeXML(-1,XMLInterface.XML_OPT_ALL_ROWS))).print(outputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
}
That's all.
Thank you very much,This is the one what I really need to used in my application.Can I download Sample application.
ReplyDeleteRegards
julykt@gmail.com
it's very useful for me. where can I download sample application.
ReplyDeleteThanks
Thank you Edwin, this helped me a lot.
ReplyDeleteOnly problem with this is that it uses FacesCtrlHierBinding, which is for internal use only. Better to use JUCtrlHierBinding instead. Works just as well.