Monday, March 26, 2012

Specifying Converter for a Dynamic UI Component


The following code snippet illustrates the API usage for setting JSF converter for a UI component added at runtime.
 RichInputDate inputDate1 = new RichInputDate();  
 Application application= FacesContext.getCurrentInstance().getApplication();  
 DateTimeConverter dateTimeConverter= (DateTimeConverter) application.createConverter("javax.faces.DateTime");  
 dateTimeConverter.setPattern("yyyy dd mm");  
 inputDate1.setConverter(dateTimeConverter);  
Tag doc  for af:inputDate says that -
Developers can programmatically attach a converter. That converter should be obtained by Application.createConverter(), rather than simply calling new DateTimeConverter(). Otherwise, some functionality will be missing, e.g. client conversion and validation, and the date picker will only display as an input field without the date-time popup (the popup relies on the client conversion and validation support)

Tuesday, March 20, 2012

Refreshing a Specific Cell in dvt:pivotTable

The following code snippet may help you to partial refresh a specific cell in dvt:pivotTable component (Thanks Chadwick Chow for this tip)
 UIPivotTable pt = getUIPivotTable();  
 CellIndex current = pt.getCellIndex();  
 try {  
      // Get desired Data Cell  
      DataCellIndex index = new DataCellIndex(2, 0);  
      // sets currency  
      pt.setCellIndex(index);  
      // ppr the cell  
      RequestContext.getCurrentInstance().addPartialTarget(pt.getCellComponent());  
 } finally {  
      // restore currency  
      pt.setCellIndex(current);  
 }  

Wednesday, March 14, 2012

Filtering af:table Without Using ADF Model

You might have seen filterable table demo in ADF Rich Client Demo App- http://jdevadf.oracle.com/adf-richclient-demo/faces/components/table/filterableTable.jspx . Today's my post is based on this item.If you want, you can download the demo source and run it locally by following the instructions given in this page http://www.oracle.com/technetwork/developer-tools/adf/documentation/adf-faces-rc-demo-083799.html

In this post I'm sharing an example illustrating table filtering with hand made FilterableQueryDescriptor. This example reuses the same implementation from rich client demo for building the custom FilterableQueryDescriptor. The TableFilterBean::processTableFilter()  method has the logic for extracting the filter criteria passed by the client. Logic for filtering the actual collection is not added - it's not there in ADF Rich Client Demo as well ;-)

Download

You can download the sample workspace from here.
Check out TableFilterBean class - You may see more code here than you expected :-)
 [Runs with Oracle JDeveloper 11g R1 11.1.1.6.0]

Friday, March 9, 2012

Forcefully Executing a View Accessor

To execute view accessor 'brutally' whenever frameworks refers view accessor row set, add the following in your parent view object implementation class.

  @Override  
  protected ViewRowSetImpl createViewLinkAccessorRS(AssociationDefImpl   
  assocDef, ViewObjectImpl accessorVO, Row masterRow, Object[] values){  
   if ("<viewlink accessor attribute name>".equals(assocDef.getName())) {  
     accessorVO.clearCache();  
   }  
   return super.createViewLinkAccessorRS(assocDef, accessorVO, masterRow,  
                       values);  
 }  



Learn More ...

There are a lot more points like this. If  you are curious to learn the internals of the ADF Business Components and ADF Binding Layer,  the following book is for you - Oracle ADF Real World Developer’s Guide.
More details about this book can be found in this post- http://jobinesh.blogspot.in/2012/07/pre-order-your-copy-of-oracle-adf-real.html