Exporting table data into Excel File in ADF

Here’s the quickest way of exporting table data into Excel File :

1) Create Model using Business Components and refresh Data Controls.
2) Create a standard and JSF page and drag-drop the control the data control to create a ADF table. Name the ID of the table as t1.
3) Create a Command Button and change the text to “Export”.
4) Refer to the snapshot below :

5) Drag-Drop Export Collection Action Listener onto the Command Button “Export”.
6) Set the following Configurations for bindings :

ExportedId : t1
Type : excelHTML

7) Set the Filename and Title in the property inspector of Export Collection Action Listener.
8) Run the page.

Author- Ankit Gupta

happy coding with Techartifact.

get object of ApplicationModule in managed bean in ADF | Techartifact

Requirment- Need an object of Application module in managed bean

Sometime we required to get an object of ApplicationModule in managed bean.May be we want to play with some VO object which we can get from
ApplicationModuleImpl Object only.

There are two ways.

First way-

        FacesContext context = FacesContext.getCurrentInstance();
        BindingContext bindingContext = BindingContext.getCurrent();
        DCDataControl dc  = bindingContext.findDataControl("AppModuleAMDataControl"); // Name of application module in datacontrolBinding.cpx
        AppModuleAMImpl appM = (AppModuleAMImpl)dc.getDataProvider();
     

Above AppModuleAMDataControl is name of application module in datacontrolBinding.cpx,open datacontrol and check the ID in tag. See below for reference.

 <BC4JDataControl id="AppModuleAMDataControl" Package="oper.model.module"
                     FactoryClass="oracle.adf.model.bc4j.DataControlFactoryImpl" SupportsTransactions="true"
                     SupportsFindMode="true" SupportsRangesize="true" SupportsResetState="true"
                     SupportsSortCollection="true" Configuration="AppModuleAMLocalWeb" syncMode="Immediate"
                     xmlns="http://xmlns.oracle.com/adfm/datacontrol"/>

Now you got the application module you can get the object of any ViewObjectImpl.

Second Way-

You can get the object of applicationModuleImpl by writing this line-

AppModuleAMImpl am = (AppModuleAMImpl)resolvElDC(AppModuleAMDataControl)

resolvElDC method is described below


private Object resolvElDC(String data) {
        FacesContext fc = FacesContext.getCurrentInstance();
        Application app = fc.getApplication();
        ExpressionFactory elFactory = app.getExpressionFactory();
        ELContext elContext = fc.getELContext();
        ValueExpression valueExp =
            elFactory.createValueExpression(elContext, #{data. + data + .dataProvider}, Object.class);
        return valueExp.getValue(elContext);
    }

Happy coding with Techartifact . 🙂

Display data for last 15 days and next 30 days in af:calendar in ADF | Techartifact.

Requirment – In calendar component , we need to show data for last 15 days and next 30 days in list mode.

Solution-Seems little tricky. But not much.Let check out in calendar property.

Well there is property called ActiveDay and ListCount. We will be binding the ActiveDay with a managed bean and setting ActiveDay from that bean.

Create a varible like “private Date currentDate;” and generate getter setter method of it in myCalendarBean. Override the getter method of current Date.

    public void setCurrentDate(Date currentDate) {
        this.currentDate = currentDate;
    }

    public Date getCurrentDate() {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DATE, -15);
        Date date = calendar.getTime();
        
        return date;
    }


And we need to show last 15 days and next 30 days. that mean total 45 days. We will putting 45 in ListCount.

See in below screenshot.Today is 18 nov. And we getting date range from 3 nov to 17 Dec. 🙂

And that all. nothing to do.

Happy Coding with Techartifact.