Please disable your adblock and script blockers to view this page

Search this blog

Showing posts with label af:poll. Show all posts
Showing posts with label af:poll. Show all posts

Monday, 15 February 2016

Show live progress of a long running task using af:progressIndicator in Oracle ADF

This post is about using af:progressIndicator to show live status of a particular task
af:progressIndicator state is tracked and maintained by it's value property that supports org.apache.myfaces.trinidad.model.BoundedRangeModel
This class has two methods

public abstract long getMaximum() { }
returns Maximum value for Model

public abstract long getValue() { }
returns value for Model (current state)

Now to see live progress on page we have to refresh progressIndicator component periodically and this can be achieved using af:poll component , poll component delivers poll events to server periodically and we can ppr (refresh) progress indicator after a particular interval

Thursday, 27 June 2013

Using af:poll to refresh and push data in page and databound table in ADF

Poll component delivers poll event to server at fixed intervals, we use poll in adf as an alternative of ADS (Active Data Service), this is very simple example of pushing data to page at some fix interval.
Basically af:poll component push data to UI from server.

  • This example contains a page with an af:table binded to Department VO, and I have used a poll component to refresh table periodically.

  • and defined pollListener on af:poll component that sends request to server in every 4 sec, and table get refreshed







  • Other approach to actively push data is ADS, but af:poll is still in use , to refresh table i have written in poll listener

  •         AppModuleAMImpl am = (AppModuleAMImpl)resolvElDC("AppModuleAMDataControl");
    
            ViewObject vo = am.getDepartment1();
            vo.executeQuery();
            i = i + 1;
            this.refreshInfo = "Data Reloaded-" + i+"  Total Row-->"+vo.getRowCount();
            AdfFacesContext.getCurrentInstance().addPartialTarget(refrshMsgBind);
    

  • See the jspx page source code-

  • <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
        <jsp:directive.page contentType="text/html;charset=UTF-8"/>
        <f:view>
            <af:document title="activePushing.jspx" id="d1">
                <af:messages id="m1"/>
                <af:form id="f1">
                    <af:panelBox id="pb1" showDisclosure="false" text="Active Data Pushing">
                        <f:facet name="toolbar">
                            <af:activeOutputText value="#{ActiveDataPushing.refreshInfo}" id="aot1"
                                                 inlineStyle="font-weight:bold;color:red;"
                                                 binding="#{ActiveDataPushing.refrshMsgBind}"/>
                        </f:facet>
                        <af:table value="#{bindings.Department1.collectionModel}" var="row"
                                  rows="#{bindings.Department1.rangeSize}"
                                  emptyText="#{bindings.Department1.viewable ? 'No data to display.' : 'Access Denied.'}"
                                  fetchSize="#{bindings.Department1.rangeSize}" rowBandingInterval="1"
                                  selectedRowKeys="#{bindings.Department1.collectionModel.selectedRow}"
                                  selectionListener="#{bindings.Department1.collectionModel.makeCurrent}"
                                  rowSelection="single" id="t1" styleClass="AFStretchWidth" contentDelivery="immediate">
                            <af:column sortProperty="#{bindings.Department1.hints.DepartmentId.name}" sortable="true"
                                       headerText="#{bindings.Department1.hints.DepartmentId.label}" id="c1" width="103">
                                <af:inputText value="#{row.bindings.DepartmentId.inputValue}"
                                              label="#{bindings.Department1.hints.DepartmentId.label}"
                                              required="#{bindings.Department1.hints.DepartmentId.mandatory}"
                                              columns="#{bindings.Department1.hints.DepartmentId.displayWidth}"
                                              maximumLength="#{bindings.Department1.hints.DepartmentId.precision}"
                                              shortDesc="#{bindings.Department1.hints.DepartmentId.tooltip}" id="it1"
                                              readOnly="true">
                                    <f:validator binding="#{row.bindings.DepartmentId.validator}"/>
                                    <af:convertNumber groupingUsed="false"
                                                      pattern="#{bindings.Department1.hints.DepartmentId.format}"/>
                                </af:inputText>
                            </af:column>
                            <af:column sortProperty="#{bindings.Department1.hints.DepartmentName.name}" sortable="true"
                                       headerText="#{bindings.Department1.hints.DepartmentName.label}" id="c2" width="107">
                                <af:inputText value="#{row.bindings.DepartmentName.inputValue}"
                                              label="#{bindings.Department1.hints.DepartmentName.label}"
                                              required="#{bindings.Department1.hints.DepartmentName.mandatory}"
                                              columns="#{bindings.Department1.hints.DepartmentName.displayWidth}"
                                              maximumLength="#{bindings.Department1.hints.DepartmentName.precision}"
                                              shortDesc="#{bindings.Department1.hints.DepartmentName.tooltip}" id="it2"
                                              readOnly="true">
                                    <f:validator binding="#{row.bindings.DepartmentName.validator}"/>
                                </af:inputText>
                            </af:column>
                            <af:column sortProperty="#{bindings.Department1.hints.ManagerId.name}" sortable="true"
                                       headerText="#{bindings.Department1.hints.ManagerId.label}" id="c3" width="105">
                                <af:inputText value="#{row.bindings.ManagerId.inputValue}"
                                              label="#{bindings.Department1.hints.ManagerId.label}"
                                              required="#{bindings.Department1.hints.ManagerId.mandatory}"
                                              columns="#{bindings.Department1.hints.ManagerId.displayWidth}"
                                              maximumLength="#{bindings.Department1.hints.ManagerId.precision}"
                                              shortDesc="#{bindings.Department1.hints.ManagerId.tooltip}" id="it3"
                                              readOnly="true">
                                    <f:validator binding="#{row.bindings.ManagerId.validator}"/>
                                    <af:convertNumber groupingUsed="false"
                                                      pattern="#{bindings.Department1.hints.ManagerId.format}"/>
                                </af:inputText>
                            </af:column>
                            <af:column sortProperty="#{bindings.Department1.hints.LocationId.name}" sortable="true"
                                       headerText="#{bindings.Department1.hints.LocationId.label}" id="c4" width="105">
                                <af:inputText value="#{row.bindings.LocationId.inputValue}"
                                              label="#{bindings.Department1.hints.LocationId.label}"
                                              required="#{bindings.Department1.hints.LocationId.mandatory}"
                                              columns="#{bindings.Department1.hints.LocationId.displayWidth}"
                                              maximumLength="#{bindings.Department1.hints.LocationId.precision}"
                                              shortDesc="#{bindings.Department1.hints.LocationId.tooltip}" id="it4"
                                              readOnly="true">
                                    <f:validator binding="#{row.bindings.LocationId.validator}"/>
                                    <af:convertNumber groupingUsed="false"
                                                      pattern="#{bindings.Department1.hints.LocationId.format}"/>
                                </af:inputText>
                            </af:column>
                        </af:table>
                        <af:poll id="p1" pollListener="#{ActiveDataPushing.pollListenerActive}" interval="4000"
                                 timeout="5000"/>
                    </af:panelBox>
                </af:form>
            </af:document>
        </f:view>
    </jsp:root>
    

  • Run your application, and do changes from Database and see updated UI at every 4 sec. :-)
 Reloading- 26th times-
 Reloading- 33th times-
 Reloading- 40th times-


Saturday, 27 April 2013

Auto dismiss popup component with dialog- Oracle ADF

af:popup is container component for noteWindow, dialog, panelWinow, contextMenus, when we use popup with af:noteWindow, there is property autoDismissalTimeout is responsible for closing poup after some specific time.
But if we are using af:dialog in af:popup , how to close popup in this situation ?

Steps to do-

  • Create a fragment in bounded taskFlow and drag a button on which we have to open popup.
  • Drag a popup in page and showPopupBehavior inside button, pass id of popup and set trigger type to action to open poup on button click
af:popup in Oracle ADF
  •  Now drag a af:poll  component inside af:dialog
poll component delivers poll event to server at  fixed intervals, so we can use this property to fulfil our requirement .
  
Drop poll component inside popup

  • Select poll component in structure window and go to propertyInspector ,create poll listener  in managed bean and set Interval and Timeout to 4000 & 4001 (Timeout slightly greater than Interval time)-It means poll event delivers to server after 4000 ms or 4second




Create a poll listener in managed bean to deliver poll event at fixed interval

  • Now bind popup component to your managed bean, inorder to control poup properties
Create Component Binding for popup in managed bean
  • Close poup in pollListener(), means when after 4sec when poll event invoke server, it will close popup dialog automatically.

Sample ADF Application- Download