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.
drag the file download action listener from the component palette to the new toolbar button
In the property window of this af:fileDownloadActionListener component we can fill in some values for the content type and filename properties.
Select the edit menu item of the method property so we create an new backing bean.
Select the edit menu item of the method property so we create an new backing bean.
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.