Tuesday, September 15, 2020

Migrating the view layer

Convert project to Facelets


1. Open the application which you would like to migrate

2. Select the view controller project and right click, from the menu select Convert to Facelets

3. Select Change Page Extensions and click preview in log

4.  


5. If everything goes well all the files would be converted into facelets and success message should be displayed.

6. Go to view controller and you should notice all the .jspx files are converted into .jsf files and .jsff stays the same.

7. This converter changes the tags in the header of the pages and fragments, adapts the libraries in the ViewController project.

8. New headline in a page based on Facelets:

<ui:composition xmlns:af=http://xmlns.oracle.com/adf/faces/rich xmlns:f="http://java.sun.com/jsf/core" xmlns:dvt="http://xmlns.oracle.com/dss/adf/faces" xmlns:ui="http://java.sun.com/jsf/facelets">


Old headline in a page based in JSP:


<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:af="http://xmlns.oracle.com/adf/faces/rich" xmlns:f="http://java.sun.com/jsf/core" xmlns:dvt="http://xmlns.oracle.com/dss/adf/faces" xmlns


Properties File

You have to take care about the used resource bundles inside a page. 

After conversion sometimes the entry of the variable which point to the correct resource bundle file is missing or the resource bundle is not recognized (highlighted with yellow warning in jdeveloper). 

If the resource bundle entry is available and the warning is issued, then delete the <c:set> entry of the resource bundle at the top of the page fragment.

You have to add one label of a component via the “Select Resource” wizard – afterward the entry is available again.

A new entry is added with the resource bundle and the values from properties file should be recognised by jdeveloper.

Migration ADF 11g to 12c - Issues and Possible solutions

 One of the clients I am working with had to migrate to ADF 12c from ADF 11g.  The migration process was not straight forward as expected. We faced many issues and had to apply several workarounds to get the application working.

I will be updating this blog with the process, issues faced and the workarounds used to overcome those issues.

Please find below the an overview of the issues.

1. Deprecated Classes

2. Issues with Templates 

3. Facelets Conversions

4. Deprecated Components

5. LDAP connection fails with "javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure"

6. Logout method deprecated

7. Filter Criteria deprecated

8. View objects broken – This one is intermittent, not all of them are broken.

9. Transient Expressions

10. java.lang.IllegalArgumentException: Script text to compile cannot be null!

11. invokeAction

For the ease of understanding I have divided the migration process into two sections
  • Migrating the View Layer
  • Migrating the Model Layer 

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);
    }

Friday, October 3, 2014

Passing bind variable value from view criteria(af:query) to next page

Issue/Scenario:

 User performs search on Employee Name and if there is no record in the data base with that name then user would click on Create employee button which takes to create employee page and the employee name should be populated with the name, user entered in the search criteria.

Solution:

Create the view criteria on the view object and create the search form based on the view criteria.

Create java implementation class for the view object on which the View Criteria is defined and make sure you include the bind variable accessors


Select the get method of bind variable and make it available to the client or in other words expose it.


Drag and drop the getinFirstName method on to the task-flow as method activity which will give us the value in the bind variable which user enters while performing the search.

As the user needs to be redirected to Create Employee page and the first name should be populated,. Follow the steps below to achieve the before mentioned.

Open the getinFirstName method page definition file and create a Create Insert operation action binding

Select the getinFirstName method activity on the taskflow and change the value of the method property to managed bean method you just created.



Place the following code in the managed bean method.

    public void createEmployee() {

        OperationBinding op = ADFUtils.findOperation("getinFirstName");
        String name = (String)op.execute();
        JSFUtils.setExpressionValue("#{pageFlowScope.firstName}", name);
        op = ADFUtils.findOperation("CreateInsert");
        op.execute();
    }
 Once you get the bind variable value you can access it either from the page flow scope or you can populate it into the new inserted row.

I am using page flow scope variable to populate the first name in the create employee page.

Your task flow should look as the screen shot below