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:

                   



Wednesday, July 29, 2015

JDeveloper Memory And Performance

As a general rule, Java is optimized for throughput, not latency. Once the garbage collector kicks in, performance drops like a rock. A 2 second pause every once in a while is OK for a server, but for an IDE it's misery. So here's the fix:


  1. Go to your JDeveloper root directory, is should be something like C:\Oracle\jdev\Middleware\jdeveloper
  2. Open the file ide\bin\ide.conf, scroll down to the default memory settings:
  3.         AddVMOption  -Xms128M
            AddVMOption  -Xmx768M
    
  4. Boost the memory to something larger, like so:
  5.         AddVMOption  -Xms1024M
            AddVMOption  -Xmx1024M
    
  6. Open the file jdev\bin\jdev.conf
  7. Add the following config settings:
  8.         # optimize the JVM for strings / text editing
            AddVMOption -XX:+UseStringCache
            AddVMOption -XX:+OptimizeStringConcat
            AddVMOption -XX:+UseCompressedStrings
    
            # if on a 64-bit system, but using less than 32 GB RAM, this reduces object pointer memory size
            AddVMOption -XX:+UseCompressedOops
    
            # use an aggressive garbage collector (constant small collections)
            AddVMOption -XX:+AggressiveOpts
    
            # for multi-core machines, use multiple threads to create objects and reduce pause times
            AddVMOption -XX:+UseConcMarkSweepGC
    
  9. Then restart JDeveloper... If it doesn't start, you'll need to reduce the amount of memory allocate in the ide.conf file from step 3.

ADF : Insert Row at the Top and Bottom of table

To insert row at the bottom of table follow followings steps:

Step 1 -  Generate VOimpl class of your  View Object.

Step 2 - Go to VOimpl class and add below code

         /**
     * Insert new Rows at the end of RowSet.
     * @param row
     */
    @Override
    public void insertRow(Row row) {
        //go to the end of Rowset if it has rows
        Row lastRow = this.last();
        if (lastRow !=null){
             //insert new row at the end and make it current
            int indx = this.getRangeIndexOf(lastRow)+1;
            this.insertRowAtRangeIndex(indx,row);
            this.setCurrentRow(row);
        }else { // empty Rowset
        super.insertRow(row);
        }
        }

In this way row always insert at bottom of table.


To insert row at the top of table follow following steps:

Step 1 - Generate VOimppl class of your View Object.

Step 2 -Go to VOimpl class and add below code,

         /**
     * Insert new Rows at the top of RowSet.
     * @param row
     */
    @Override
    public void insertRow(Row row) {
        //go to the First of Rowset if it has rows
        Row firstRow = this.first();
        if (firstRow !=null){
             //insert new row at the top and make it current
            int indx = this.getRangeIndexOf(firstRow);
            this.insertRowAtRangeIndex(indx,row);
            this.setCurrentRow(row);
        }else { // empty Rowset
        super.insertRow(row);
        }
        }

In this way row always insert at top of the table.


Tuesday, July 21, 2015

ADF-How To call and Execute sql function Programatically (using operationBinding.getParamsMap() )

Most of the scenarios , we need to call sql function pragmatically.

Here, is the one approch by using Map we can put input parameter to function and get result as Object.

1- Suppose we have Login Table as follows:

2-we want to fetch name of particular user id. So, for that we will create function is database as follows.

3-Now create Application Test ,create Login EO, LoginVO,
4-In AppModuleImpl.class write following method to get result from database.



5-From  Managed Bean call above method as follows:

    OperationBinding operationBinding =
                 (OperationBinding) bindings.getOperationBinding("getName");//AppModuleImpl.class method Name
operationBinding.getParamsMap().put("id", <Pass ID here>);
Object result = operationBinding.execute();//we can get Name of that user Id in result Object


ADF- How to Apply and Create View Criteria Programatically


   

 1.   I have already created a view criteria in EmployeeVO, and I want to call it programmatically.

                public void searchEmployee(Number employeeId) {
                            ViewObjectImpl vo = getEmployeesView1();    
                            ViewCriteria vc = vo.getViewCriteria("findEmployeeVC");   
                            vo.applyViewCriteria(vc);               
                            vo.setNamedWhereClauseParam("pEmployeeId", employeeId);    
                            vo.executeQuery();            
                 }


    2.    I want to create a view criteria dynamically and execute it programmatically.

                   public void searchByEmployeeIdEmail(Number employeeId, String email) {
                                   ViewObjectImpl vo = getEmployeesView2();
                                   ViewCriteria vc = vo.createViewCriteria();
                                   ViewCriteriaRow vcRow = vc.createViewCriteriaRow();
     
                                    vcRow.setAttribute("EmployeeId", employeeId);
                                    vc.addRow(vcRow);
                                    vcRow.setAttribute("Email", email);
                                    vc.addRow(vcRow);
     
                                    vo.applyViewCriteria(vc);
                                    vo.executeQuery();
                    }