Tuesday, October 30, 2018

Reset All filters for af:table columns

    public String resetAllFilters() {
        //System.out.println("-- it1 "+t.getValue());
        FilterableQueryDescriptor queryDescriptor = (FilterableQueryDescriptor)this.getResId1().getFilterModel();
        System.out.println("---- query desc : "+queryDescriptor+"   filter crti : "+queryDescriptor.getFilterCriteria());
       // Map x=queryDescriptor.getFilterCriteria();
        if (queryDescriptor != null && queryDescriptor.getFilterCriteria() != null) {
            queryDescriptor.getFilterCriteria().clear();
            this.getResId1().queueEvent(new QueryEvent(this.getResId1(), queryDescriptor));
            System.out.println("-- after clear");
        }
       // FilterableQueryDescriptor eqd=(FilterableQueryDescriptor)qe.getDescriptor();
               ConjunctionCriterion cC=queryDescriptor.getConjunctionCriterion();
               System.out.println("--- conj : "+cC);
               List<Criterion> cl=cC.getCriterionList();
               System.out.println("-- list  : "+cl);
               for(Criterion c:cl){
                   AttributeDescriptor ad=((AttributeCriterion) c).getAttribute();
                   System.out.println("-- att : "+ad);
                   System.out.println("-- attr name : "+ad.getName());
                   System.out.println("-- get values : "+((AttributeCriterion) c).getValues().get(0));
                   Object val=((AttributeCriterion) c).getValues();
                   System.out.println("Object : "+val);
               }
        return null;
    }

Garbage Collection in JDeveloper

53. Garbage Collection in JDeveloper
Issue: Often times, JDeveloper stops responding or automatically shuts down due to lack of memory. There are few ways to handle Out of Memory issues.
To perform monitoring and proactively do the garbage collection, here is a small hack.
1. Go to: C:\Oracle\Middleware\jdeveloper\jdev\bin(Or where ever JDeveloper is installed)
2. Edit jdev.conf file and add this line at the end
AddVMOption -DMainWindow.MemoryMonitorOn=true
3. Restart JDeveloper. You can see the Recycle bin and the memory details on the bottom right of JDeveloper.
When the Heap size grows, JDeveloper obviously gets slow. So, just click on the Recycle bin to clean up.

=====================

Proactively Monitoring JDeveloper 11g IDE Heap Memory

There is possibility to monitor during runtime consumed heap and permgen memory by JDeveloper IDE process. It will show consumed memory, also allows to force garbage collection. This can be extremely useful when running JDev on less powerful hardware - developer could force garbage collection, just before entire memory is consumed and JDeveloper is freezing.

This post is based on JDev 11g R2 (but same applies for other JDev 11g versions).

Its fairly easy to enable JDeveloper 11g Heap Memory Monitor, add this property to jdev.conf file (located under JDEV_INSTALL/jdev/bin/ folder) and restart IDE:

AddVMOption -DMainWindow.MemoryMonitorOn=true



You will see in the IDE lower right corner - heap and permgen memory statistics will be available, along with garbage collector button:


I did a quick test - opened one JSPX file in Designer mode. Heap memory consumption increased from 90M to 256M, PermGen from 82M to 124M:


Next I invoked garbage collection process by clicking recycle bin icon:


Heap memory usage instantly dropped to 176M:


Don't worry, memory consumption is quite stable and not growing over time. I was trying to open multiple complex pages, close and open again - IDE was acquiring and then after some time releasing memory. It was consuming around 300M - 400M heap and 200M PermGen memory, when working with complex pages/fragments and ADF BC wizards:


Maximum range for heap memory is set in ide.conf file (located under JDEV_INSTALL/ide/bin/ folder). Default value of 800M is usually enough for ADF development:

Wednesday, October 24, 2018

Dump VO query and it’s parameter with their values


import oracle.jbo.VariableValueManager;
import oracle.jbo.Variable;

public void dumpQueryAndParameters()
{
    // get the query in it's current state
    String lQuery = getQuery();
    //get Valriables
    VariableValueManager lEnsureVariableManager = ensureVariableManager();
    Variable[] lVariables = lEnsureVariableManager.getVariables();
    int lCount = lEnsureVariableManager.getVariableCount();
    // Dump query
    System.out.println("---query--- " + lQuery);
    // if variables found dump them
    if (lCount > 0)
    {
        System.out.println("---Variables:");
        for (int ii = 0; ii < lCount; ii++)
        {
            Object lObject = lEnsureVariableManager.getVariableValue(lVariables[ii]);
            System.out.println("  --- Name: " + lVariables[ii].getName() + " Value: " +
                               (lObject != null ?  lObject.toString() : "null"));
        }
    }
}


You can overwrite the executeQuery() method of the ViewObjectImpl class and call the method above like

@Override
public void executeQuery()
{
    dumpQueryAndParameters();
    super.executeQuery();
}