Monday, November 16, 2015

Remove the close icon from task flow opened in dialog


How-to remove the close icon from task flows opened in dialogs 

https://blogs.oracle.com/jdevotnharvest/entry/how-to_remove_the_close_icon_from_task_flows_opened_in_dialogs_11114

Wednesday, October 14, 2015

Create a new row programmitically

Several ways to create new row:

createrow() or createAndIntRow()
http://mahmoudoracle.blogspot.ca/2012/03/insert-rows-in-adf-view-object.html

control the insert location in table
https://mjabr.wordpress.com/2011/07/02/how-to-control-the-location-of-the-new-row-in-aftable/

Thursday, September 24, 2015

ADF action binding with Generics

ADF binding does not support Generics See below,

https://community.oracle.com/message/4304798

For example, in AM you have List<Long> getListCount() {}, you will get following exception.

Go to binding source, change following

<NamedData NDName="testList" NDType="java.util.List&lt;java.lang.Long>"/>
to
<NamedData NDName="testList" NDType="java.util.List"/>


Exception
oracle.jbo.InvalidOperException: JBO-25221: Method TestAppModuleDataControl.dataProvider.doSomethingWithList() not supported
     at oracle.adf.model.binding.DCInvokeMethod.invokeMethod(DCInvokeMethod.java:491)
     at oracle.adf.model.binding.DCDataControl.invokeMethod(DCDataControl.java:2134)
     at oracle.adf.model.bc4j.DCJboDataControl.invokeMethod(DCJboDataControl.java:3020)

Friday, September 18, 2015

Page jsff not a source file warning

Warning: java.lang.IllegalArgumentException: The file file:<directory listed here>\DepartmentsView.jsff is not a source file

https://blogs.oracle.com/jdevotnharvest/entry/warning_java_lang_illegalargumentexception_the

<!-- 
  * WORK AROUND
  * randomly, when editing files, compilation fails with an illegal argument exception
  * java.lang.IllegalArgumentException: The file <file name> .jsff is not a source file
  * To avoid this error, which initially has been reported as bug 12732652 for Facelets
  * I added the jsp-property-group entry below
 -->
 <jsp-config>
  <jsp-property-group> 
    <url-pattern>*.jsff</url-pattern>
    <is-xml>true</is-xml>
   </jsp-property-group>
  </jsp-config>
 <!-- 
  * END WORK AROUND
  -->

Monday, August 31, 2015

ADF Install tag lib


Add following to jsff
xmlns:c="http://java.sun.com/jsp/jstl/core"

But got complaint error:
Tag library referenced Tag library referenced but not installed

Go to
Project --> Select Project Property --> Select JSP Tag libraries 

There you can add library needed.

Thursday, August 27, 2015

ADF Table with context menus

We can add ADF Table context menus so user right clicks on a row, the context menu will be displayed.


add a facet to table
<af:table>
        <f:facet name="contextMenu">
           <af:popup id="cmpop" contentDelivery="lazyUncached">
               <af:menu id="cmm1" text="My Context Menu">
                  <af:commandMenuItem text="Do something"
                          id="cmi1"
                          actionListener="#{backingBeanScope.myBean.myActionListener}"/>
               </af:menu>
          </af:popup>
        </f:facet>
</af:table>
 Table has another property:
          contextMenuSelect="true" so this ensures the right click on a row will make the row selected and context menu shows up.

Note:

  • add <af:showPopupBehavior triggerType="contextMenu" popupId="cmpop"/> if you like for table columns for context menu display
  • add partial triggers so UI refreshes after context menu execution.

Wednesday, August 26, 2015

Refresh adf region without contextual event

The trick is region will refresh whenever its input parameter changes.

  • Go the page with the region which will be refreshed.
  • Go to binding tab and select the region from Executables
    • add an input parameter id=refreshInd value=#{pageFlowScope.dummyParam}
    • set Refresh=ifNeeded
So any point, you want the region to refresh, 

ADFUtils.getPageFlowScope().put("dummyParam", Long.toString(System.currentTimeMillis()));

Another trick is using current mill second as input value - that's guaranteed to have a new value for the input.

Thursday, August 20, 2015

Missing IN or OUT parameter error in ADF binding variable


See blog psot below:

The infamous Missing IN or OUT parameter error

In short:
make sure the bind variables are set to required. Bind variables that are marked as optional are only good to be used in View Criterias.

Wednesday, August 19, 2015

Complie warning for ADF project


There is a warning while building a ADF project in JDeveloper 11.1.1.9.

Warning: Supported source version 'RELEASE_6' from annotation processor 'oracle.dbtools.common.service.ConfigProcessor' less than -source '1.7'

The problem is we are using JDK 1.7 instead of default 1.6.

Go to Project Properties -> Compiler, setting is default


change default Source 1.6, Generated Class Files 1.7 the warning is disappeared.



 

Tuesday, August 18, 2015

ADF Error Handling

Exceptions are thrown in different places or layers of the ADF application. ADF framework allow applications to register general error handlers on different layers. 



Task Flow Error Handling

Create a task flow called base-taskflow-template.xml. 

In base-taskflow-template.xml, 
  • create a bean class TashFlowErrorHandler. In the class, create a method called 
public void handleException() {//add handling logic}
  • add it to base-taskflow-template.xml as request scope.
  • add a method-call named ErrorHandler, marked it as Exception Handler.
All task flows extend base-taskflow-template.xml. So exceptions are handled by the registered handler.



Bean Exception Handling

When the ADF view layer calls a method from a managed bean and this method throws an exception, the default ADFExceptionHandler is called. To override the default behavior,  

Create class BeanExceptionHandler
public class BeanExceptionHandler extends ExceptionHandler

To register the exception handler, create a file called "oracle.adf.view.rich.context.ExceptionHandler"
add text (class full qualified name) in the file:

com.abc.view.util.BeanExceptionHandler

put this file in master application (deployed as ear file) under folder below (create if doesn't exist)

.adf\META-INF\services




Binding Error Handler

Managed bean may call Application Module methods by DataControls. Such calls use the bindings which are handled by the DataBindings.cpx mainly. 

Create a class called 
public class BindingErrorHandler extends DCErrorHandlerImpl

In master application DataBindings.cpx, we define the ErrorHandlerClass="com.abc.view.util.BindingErrorHandler




Wednesday, July 29, 2015

UIComponent binding in cluster environment


There are two posts mentioned about how UIComponent buiding works in cluster environment:

http://www.ateam-oracle.com/rules-and-best-practices-for-jsf-component-binding-in-adf/
https://adfblog.wordpress.com/2014/08/14/adf-for-high-availability/

in short,
  • All Manage Beans must implement Serializable.
  • UI component bindings must be declared in a bean with shorter scope (backing bean scope or request scope).
  • If it needs to be declared in Manage Bean with PageFlowScope (Not recommended), please ensure you declare the binding as transient.
  • ......

And interested in the class below:
org.apache.myfaces.trinidad.util.ComponentReference
https://java.net/jira/browse/ADFEMG-202

Wednesday, June 10, 2015

locale set up in ADF pages

For a page to change language and formatting of date, we need to set user locale

<f:view locale="#{sessionScope.UserLocale}"...

Friday, January 30, 2015

ADF Component id and clientId

When we drag a ADF component to a page, ADF will generate an id like below:

<af:inputText id="it1" />

The id attribute rendered in the browser is obviously not the same as the value set in the ADF apge. This new id is the clientId and is produced by the UIComponent.getClientId(FacesContext) method.

public String getClientId(String componentId) {
    FacesContext context = FacesContext.getCurrentInstance();
    UIViewRoot root = context.getViewRoot();    
    UIComponent c = findComponent(root, componentId);
    return c.getClientId(context);
}

One good example of using client id is to display error message on a specific field.

The field will has a red border and mouse over to see the error message.
    
public static void displayMessage(Severity messageType,
                                      String messageTitle, String messageText,
                                      String componentId) {
        String clientId = null;
        if (componentId != null) {
            clientId = getClientId(componentId);
        }
        FacesContext fc = FacesContext.getCurrentInstance();
        FacesMessage message = new FacesMessage(messageTitle, messageText);
        message.setSeverity(messageType);
        fc.addMessage(clientId, message);

}




Wednesday, January 21, 2015

How to write CSS class in ADF


Following is an example of write CSS class. The advantage of using CSS class is to apply style to a specific component and do not affect the same component on other pages.

  1. .yourClassName af|inputFile:update::content span:first-of-type {   
  2.     max-width230px;   
  3.     display: inline-block;   
  4.     overflowhidden;   
  5.     text-overflow: ellipsis;   

Wednesday, January 7, 2015

RowSetIterator next never returns null, causing infinite loop

The recommended way of using "RowSetIterator" for a view object:

Always create a "Secondary Row Set Iterator" and close it when finished.
Do not use getRowSetIterator() as it impacts row currency on the front end so firstly you should use createRowSetIterator and you should call closeRowSetIterator on the iterator created through this because if you don't, framework will create new ViewRowSetIteratorImpl instances and keep on adding them.

Code example:
DCBindingContainer bc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
EmpVOImpl empVoImpl=(EmpVOImpl)bc.findIteratorBinding("EmpVO1Iterator").getViewObject();
    
RowSetIterator it = empVoImpl.createRowSetIterator(null);
while(it.hasNext()){
    EmpVORowImpl row=(EmpVORowImpl)it.next();
    if(row.getSal()!=null){
        totalAmount=row.getSal().add(totalAmount);
    }
}
it.closeRowSetIterator();
If necessary, use finally block

           try{
               while(it.hasNext()){
            EmpVORowImpl row=(EmpVORowImpl)it.next();
            if(row.getSal()!=null){ 
                  totalAmount=row.getSal().add(totalAmount);
            }
        }
} catch(Exception e) {
              //handle here
} finally {
      it.closeRowSetIterator();
}

Please refer to the links below for the issue:
https://community.oracle.com/thread/2242010
http://ramannanda.blogspot.ca/2013/04/adf-examining-memory-leaks.html
http://adfbugs.blogspot.ca/2009/07/iterating-through-view-object.html

https://community.oracle.com/message/12788828#12788828