Thursday, August 20, 2015

ADF : Refresh the parent view when a taskflow displayed in a popup returns


- Refreshing the parent view when an in-line popup taskflow returns.

This scenario usually arises when the second task flow updates tables used by the first one from a different transaction context. 

There are two taskflows, both work with separate transaction contexts(Transaction attribute is set as new-transaction). Second taskflow is invoked from the first one as a dialog. The requirement here is to refresh the 'executables' of calling page(from first taskflow) when the second taskflow returns. 



createWO view from first task flow.

truckCompTF is the second taskflow.


- Define a returnListener for secondary window on the command button (which invokes second taskflow as dialog)

- Create method as dialogReturnListener in returnListner and copy below code

    public void dialogReturnListener(ReturnEvent returnEvent) {
        BindingContext bc = BindingContext.getCurrent();
          DCBindingContainer dcb =
            (DCBindingContainer)bc.getCurrentBindingsEntry();
          DCIteratorBinding iter =
            dcb.findIteratorBinding("TransportUnitVOIterator");   //your VOIterator 
          iter.executeQuery();         // It refresh the underlying IteratorBindings used by the parent page. 
       RequestContext.getCurrentInstance().addPartialTarget(returnEvent.getComponent().getParent().getParent());

    }


Tuesday, August 4, 2015

ADF - How-to show a glasspane and splash screen for long running queries


A Glass Pane is a pop-up that prevents user-input while a large database job or query is running in the background. It uses a splash screen with an animated image giving the impression of activity while the job completes.

The Glass Pane will consist of a pop-up that is activated by a javascript function included in the page-template.

Add Javascript File and Popup to Page Template:

Add the Popup in the Template as follows:

 <af:popup id="Busypopup"  contentDelivery="immediate">
                <af:dialog id="d2" type="none" closeIconVisible="false" title="File uploading...">
                    <af:panelGroupLayout id="pgl5" layout="vertical">
                        <af:image source="/resources/images/1processing.gif" id="i1"/> 
                    </af:panelGroupLayout>
                </af:dialog>
            </af:popup>

Include below Javascript code in the Template by using a Resource component.



function enforcePreventUserInput(evt) {
              var popup = AdfPage.PAGE.findComponentByAbsoluteId('pt1:Busypopup');
              if (popup != null) {
                  AdfPage.PAGE.addBusyStateListener(popup, handleBusyState);
                  evt.preventUserInput();
              }
          }
              function handleBusyState(evt) {
                  var popup = AdfPage.PAGE.findComponentByAbsoluteId('pt1:Busypopup');
                  if (popup != null) {
                      if (evt.isBusy()) {
                          popup.show();
                      }
                      else if (popup.isPopupVisible()) {
                          popup.hide();
                          AdfPage.PAGE.removeBusyStateListener(popup, handleBusyState);
                      }
                  }

              }

In above Code , pt1 is the page template id and Busypopup is the popup id.
pt1:Busypopup by this we get the address of popup.



Client Listener

On the button that calls the query or database job add a clientListener.
Ensure the PartialSubmit of the button is set to true (the default)


Add enforcePreventUserInput as the method (the javascript function we created earlier)


For  <af:inputFile> component use Type -> click in Client Listener
For  <af:button>     component use Type -> action in Client Listener


Output:



Monday, August 3, 2015

ADF- Checkbox selection will be calculated using Groovy, based on additional helper attribute.

In this blog we will see how to select or deselect checkbox value:

Steps:

Create your EO and VO of Table.
In this Example , i have TransportUnitVO. Here,I want to set a check box value (true or false) to attribute Discard.


create one new transient attribute of type Boolean named as CheckedDis and write groovy as follow in expression field of that attribute.

 Now in a page create one column, drag and drop this attribute in it.
On value changed write below Code in managed bean:

public void discardCheck(ValueChangeEvent valueChangeEvent) {
       Row  row = ADFUtils.getSelectedCurrentRow("TransportUnitVOIterator");
        if(valueChangeEvent.getNewValue().toString().equalsIgnoreCase("true")){
            row.setAttribute("Discard", "true");
        }else{
            row.setAttribute("Discard", "false"); 
        }
    }

After drag and drop, in a page source should be:

<af:selectBooleanCheckbox value="#{row.bindings.CheckedDis.inputValue}"
                                               label="#{row.bindings.CheckedDis.label}"
                                       shortDesc="#{bindings.TransportUnitVO.hints.CheckedDis.tooltip}"
                                     autoSubmit="true" immediate="true" id="sbc1" 
                      valueChangeListener="#{workOrderBean.discardCheck}"/>



Save all changes and run Page:

Output:
After saving details of TransportUnitVO value inserted of attribute Discard is true or false: