Sunday, December 1, 2013

Refactoring DataBindings.cpx file and Having Multiple cpx files

I found some interesting facts while I was playing with DataBindings.cpx file this weekend and I'm blogging them now after a long time.
  • Renaming the default DataBindings.cpx file.
  • Having more than one DataBindings file in a project.
       As you know the DataBindings.cpx file plays a vital role in the ADF Model layer, which is used to create the BindingContext for the Web Application by ADFBindingFilter and this stores the meta info about page defintions mappings to create the Binding Container for ADF data bound pages and DataControl usages to find the appropriate AppModules and ErrorHanler config,etc.

       JDeveloper does not provide declarative facility to rename or move the DataBindings.cpx file. To rename or move the DataBindings.cpx file, just create the new one and delete the existing one. While doing this don't forgot to update the adfm.xml file which is the registry of registries and always have the id property is same as the DataBindings cpx file name otherwise you will get error message  "DataControl is not found".

For example if you are renaming the cpx file from DataBindings.cpx to MyDataBindings.cpx, update the id as follows.

DataBindings.cpx file

<?xml version="1.0" encoding="UTF-8" ?>

<Application xmlns="http://xmlns.oracle.com/adfm/application"
             version="11.1.1.61.92" id="DataBindings" SeparateXMLFiles="false"
             Package="view" ClientType="Generic">
.........................
.........................
</Application>

MyDataBindings.cpx

<?xml version="1.0" encoding="UTF-8" ?>
<Application xmlns="http://xmlns.oracle.com/adfm/application"
             version="11.1.1.61.92" id="MyDataBindings" SeparateXMLFiles="false"
             Package="view" ClientType="Generic">
.........................
.........................
</Application>

         If you want to have more than one DataBindings.cpx file in a project, then  add the entries in the adfm.xml file, because ADFBindingFilter looks for the cpx files in the adfm.xml file. Cpx file names should be unique within the project.

Sample adfm.xml for multiple cpx files.

<?xml version="1.0" encoding="UTF-8" ?>

<MetadataDirectory xmlns="http://xmlns.oracle.com/adfm/metainf"                                      
                                                             version="11.1.1.0.0">
  <DataBindingRegistry path="view/DataBind1.cpx"/>
  <DataBindingRegistry path="view/DataBind1.cpx"/>
  <DataBindingRegistry path="view1/DataBind2.cpx"/>
</MetadataDirectory>



Note:  It is best practice to have cpx file name as DataBindings.cpx and having only one cpx file if we don't have special use cases.



Wednesday, March 28, 2012

ADF client side validations with inbuilt validation tags


Validate maximum length;
<af:inputText id="id0" value="12A" label="Maximum length validator">
<af:validateLength maximum="5"/>
</af:inputText>
Validate minimum length;
<af:inputText id="id00" value="12A" label="Minimum length validator">
<af:validateLength minimum="3"/>
</af:inputText>
Validate length range;
<af:inputText id="id01" value="12A" label="Length Range Validator">
<af:validateLength minimum="1" maximum="5"/>
</af:inputText>
Validate long range;
<af:inputText id="id2" value="10" label="Long Range Validator">
<af:validateLongRange minimum="5" maximum="50"/>
</af:inputText>
Validate double range;
<af:inputText id="id3" value="8.6" label="Double Range Validator">
<af:validateDoubleRange minimum="4.1" maximum="8.9"/>
</af:inputText>
Validate regular expression;
<af:inputText id="id4" value="9999" label="Regular Expression validation">
<af:validateRegExp pattern="[9]*"/ >
</af:inputText>
Date validation with filter condition;
<af:inputDate id="id5" value="2011-05-21"
label="Select a date, but not a Friday">
<af:convertDateTime pattern="yyyy-MM-dd"/>
<af:validateDateRestriction invalidDaysOfWeek="Fri"/>
</af:inputDate>
Validate date range;
<af:inputDate id="mdf3ee" value="2011-11-25" label="Submission period">
<af:convertDateTime pattern="yyyy-MM-dd"/>
<!-- Supports ISO date format strings of the form "yyyy-MM-dd" -->
<af:validateDateTimeRange minimum="2011-11-16" maximum="2011-12-16"/>
</af:inputDate>

Saturday, January 21, 2012

Set and get object into/from session

/**
* Method for setting an object in session
* @param name
* @param value
* @return null
*/
public static void setSessionValue(String name, Object value) {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request =
(HttpServletRequest)context.getExternalContext().getRequest();
HttpSession httpSession = request.getSession(false);
httpSession.setAttribute(name, value);
}
/**
* Method for getting an object from session
* @param null
* @return Object
*/
public static Object getSessionValue(String attName) {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request =
(HttpServletRequest)context.getExternalContext().getRequest();
HttpSession httpSession = request.getSession(false);
return httpSession.getAttribute(attName);
}

Friday, January 20, 2012

Some more usefull methods in ViewObjectImpl

1.getFilteredRows(java.lang.String attrName, java.lang.Object attrValue)
          Returns all rows in this collection whose attribute value matches the value being passed in attrValue.

 2.getRow(Key key)
          Returns the first row matching a given key.

 3.setCurrentRow(Row row)
          Designates a given row as the current row.
 getCurrentRow()
          Returns the current row of the iterator.

for more info
ViewObjectImpl API

Sunday, January 8, 2012

jdevloper not taking the latest changes – what to do?

Sometime when you do the changes and run the application the latest changes are not updated while running the application.
The culprit is the system folder.
{user_home}\system11.1.1.4.37.57.75\o.j2ee\drs\
has the exploded war file which will have the classes that is old. deleting the classes from the exploded directory would definitely fix the issue.

Enable FastSwap in Weblogic deployment to load java classes at runtime without relaoding the classloader

 Fast Swap
Specifies whether FastSwap deployment is used to minimize redeployment since Java classes are redefined in place without reloading the ClassLoader. For more information, see "Using FastSwap Deployment to Minimize Redeployment" in Deploying Applications to Oracle WebLogic Server.

Enable Class Redefinition
Select to enable FastSwap.

Refresh Interval
FastSwap checks for changes in application classes when an incoming HTTP request is received. Subsequent HTTP requests arriving within the number of seconds specified here will not trigger a check for changes. The first HTTP request arriving after the number of seconds specified here have passed, will cause FastSwap to perform a class-change check again.

Redefinition Task Limit
Specifies the number of redefinition tasks that will be retained by the FastSwap system. If the number of tasks exceeds this limit, older tasks are automatically removed.


The following types of changes are supported with FastSwap:
  • Addition of static methods
  • Removal of static methods
  • Addition of instance methods
  • Removal of instance methods
  • Changes to static method bodies
  • Changes to instance method bodies
  • Addition of static fields
  • Removal of static fields
  • Addition of instance fields
  • Removal of instance fields

Wednesday, December 8, 2010

JavaScipt Code to close a popup

var popup = AdfPage.PAGE.findComponent("popupId"); 
          if (popup.isPopupVisible() == true){
              popup.hide();
          }