Thursday, October 27, 2016

Issue with ADF Popup Fetch Listener

Issue when popup fetch listener is added

Issue


  While working with ADF popup the developer wanted to use ADF buttons instead of the default buttons generated by af:dialog. 

 Method binding for  Popup fetch listener was added on af:popup

  Dialog type was set to none and two command buttons (Save and Cancel) were placed in the af:dialog .

 Save button was data bind with Commit operation and for Cancel an action listener method was added which is placed in Managed bean.

Code in the page now should look like the below screenshot.







Once the user clicks on Save and Close, it was all fine, the records were saved to the database and reflected in the UI.

But the issue was with Delete button, the action listener was never called. At first I thought I missed the debug code :) but to my dismay it was not the case.

After much of debugging I realised that there is nothing wrong with the button nor the action listener method.

Solution


Removed the method binding for popup fetch listener and the delete button started to work as expected.

I am not sure whether this is the solution or this is the way af:popup/af:dialog works.  I might be very naive in not knowing this behaviour as well.

Thursday, June 16, 2016

Shared Libraries - Wrong page displayed at runtime.

Problem :  While fixing a bug, one of the developers was changing the page to add a new attribute and some validation.  While running from local JDeveloper everything was fine, all the changes were replicated and the page was behaving properly, but as soon as we deploy it on the standalone weblogic server as a shared library the changes were not seen.

Solution: 

To investigate the solution, I have started looking at the problem.

1. Being deployed as shared libraries, the initial thought was the shared library is not built properly and hence the behaviour.

  - Cleared all the classes, deleted the shared libraries, re-generated the library and deployed again but still the same behaviour.

2. Now the next thought was the manifest version of the shared library was not correct and it is still taking the code from old version of shared library

 - Checked the manifest version on the server, everything looked fine, but still same behaviour.

3.  It was a random thought and started looking for the page name (in which developer was making the changes)eg., employee.jsff in the entire application.
 
  - Found instances of the same page name at the same path in a different application as of the page on which the developer is working.

Please find the path of the page fragments in both the applications.
 

Application 1

App1ViewController
-Applciation Sources
  - Fragments
      - EmployeePageDef.xml
-Web Content
  - Fragments
     - Employee.jsff


Application 2

App2ViewController
-Applciation Sources
  - Fragments
      - EmployeePageDef.xml
-Web Content
  - Fragments
     - Employee.jsff

Now I went to change the label of a attribute in the page of application 2 and redeployed the shared library.

And wonder what, the changes started to show up.

And finally the random thought was, if there are two similar pages at similar path in two different shared libraries, at runtime the page which was available first was displayed.

Finally the solution is to rename the pages and page def files simply to make the path different and everything was fine.


Thursday, February 11, 2016

Reset Sort and Filter Criteria

Issue: Clearing the values entered in QBE (Query by example) and Sort fields of a table


If the user enters a value in the QBE or filter and perform some kind of sort on fields above the header of the attribute columns the values are not cleared even after reset.  

It keeps the values and applies the Sort and filter criteria even after reset and search.


Solution:




The utility method below would clear out both the filter and Sort criteria applied by the user on click of reset.

The utility method takes the results table and the Iterator as the input and clears the sort and filter criteria applied by the user.

To call the method you have to write the custom query operation listener and check if the operation name is RESET.

public static void clearFilterCriteria(RichTable targetTable, String       iterator) {
targetTable.queueEvent(new SortEvent(targetTable,new                           ArrayList<SortCriterion>()));
SortCriteria[] sc = new SortCriteria[0];
        //Clears the Sort Criteria        ADFUtils.findIterator(iterator).applySortCriteria(sc);
FilterableQueryDescriptor queryDescriptor =            (FilterableQueryDescriptor)targetTable.getFilterModel();  
if (queryDescriptor != null && queryDescriptor.getFilterCriteria() != null) {           // Clears the Filter Criteria            queryDescriptor.getFilterCriteria().clear();}
}
}


Cascading LOV : Default Value

Issue: In Cascading LOV's if one of the child LOV's had single value then it should be selected by default as soon as the user selects the value in parent LOV


Solution: 

The trick is to access the ViewAccessor of the LOV, check the estimated row count and if it is 1 then get the value and set it to the attribute of the View object.

Creating RowImpl for the view object and in the getter of the attribute add the following code


    /**     * Gets the attribute value for the calculated attribute LocationId.
     * @return the LocationId
     */
    public Number getLocationId() {
        return this.getLocationsLOV1().getRowCount() == 1
                 ? ((DBSequence)this.getLocationsLOV1().first().getAttribute("LocationId")).getSequenceNumber()
                 : (Number)getAttributeInternal(LOCATIONID);
    }