ADF Code Corder 42: by using a < af:poll > with an Application Module

Hi all

With the help of JDev 11.1.2.3.0.

I worked to solve this puzzle for a while.  I'm trying to implement a simplified version of the ADF Code corner #42 (http://www.oracle.com/technetwork/developer-tools/adf/learnmore/42-progressbarcolor-169184.pdf)

The thing is that my 'business ' service is running in my module of the application.  In short, I take 10,000 rows to view object and run through a few different algorithms.  It would be nice to give a report during this operation.  However, as soon as I start my method of request module, my component < af:poll > end, refusing to update the current page.

I watched a lot of sites tutorials to try to solve this problem.  I try to stay within the limits of the ADF Essentials which means no ADVERTISING, only of the poll.  Here are some of the best references:

GEBS | Oracle Fusion Middleware 11g ADF progress indicator

Refresh the page periodically by using survey components |

Their service 'business' in the managed bean and the other simply re - runs a page runs a view object.  I can't find a site that will their own business service and surveys it.  Here's what I have:

Application module

    private long uploadStatus;


    public void doUpload() {
        long max = this.getMaximum();
        for(this.uploadStatus = 0; this.uploadStatus <= max ; this.uploadStatus += 500){
            System.out.println("@ " + this.uploadStatus);
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("Upload Complete");
    }

    public long getStatus(){
        return this.uploadStatus;
    }

    public long getMaximum(){
        return 10000;
    }

Backing Bean

public class ProgressBarModel extends BoundedRangeModel {

    private long max;
    private long status;

    Thread newProgress = null;

    public ProgressBarModel() {
        this.getMaximum();
        this.getValue();
    }

    @Override
    public long getMaximum() {
        // Not best practice. Should get through page def method operation
        AppModuleImpl am = (AppModuleImpl)ADFUtils.getApplicationModule("AppModuleDataControl");
        this.max = am.getMaximum();
        return this.max;
    }

    @Override
    public long getValue() {
        System.out.println("polling ...");
        AppModuleImpl am = (AppModuleImpl)ADFUtils.getApplicationModule("AppModuleDataControl");
        this.status = am.getStatus();
        return this.status;
    }

    public void doUpload(ActionEvent actionEvent) {
        if (newProgress != null) {
            newProgress.interrupt();
        }

        ProgressUpdater progressSimulator = new ProgressUpdater();
        newProgress = new Thread(progressSimulator);
        newProgress.run();

    }

    public void stopUpload() {
        newProgress.interrupt();
        newProgress = null;
    }

    class ProgressUpdater implements Runnable {
        public void run() {
            AppModuleImpl am = (AppModuleImpl)ADFUtils.getApplicationModule("AppModuleDataControl");
            am.doUpload();
        }
    }

    public long getPercentageUploaded() {
        long state = this.status * 10 / 10000;
        if(state >= 100){
            this.stopUpload();
        }
        return this.status * 100 / 10000;
    }
}

JSPX

<af:panelFormLayout id="pfl1">
                                <af:poll id="pollid" interval="1000"/>
                                <af:outputFormatted value="#{MyProgressRangeModel.percentageUploaded}% completed"
                                                    id="of1" partialTriggers="pollid"/>
                                <af:commandToolbarButton actionListener="#{MyProgressRangeModel.doUpload}" text="Run"
                                                        id="ctb1"/>
</af:panelFormLayout>

Give me the result

polling ...
polling ...
polling ...
@ 0
@ 500
@ 1000
@ 1500
@ 2000
@ 2500
@ 3000
.... // up to 10000
Upload Complete
polling ...
polling ...

How can I get the survey allows you to control when the method of the module of an application is running?  Use more than one module app, for inclusion in the database and the other for monitoring?

Thank you

Will be

I went with that instead

How I finally reached updates to asynchronous UI with WebSockets and JMS

Tags: Java

Similar Questions

Maybe you are looking for