Java Bean DC extension for JDeveloper with declarative search capability

A while back I blogged about extending Java Bean Data Control to add some useful  features such as declarative view criteria support. If you have not  seen it , here is the link: http://www.jobinesh.com/2014/01/customizing-pojo-based-bean-data.html

In this post I'm sharing the same solution as JDev extension. With  this extension, you can leverage the built-in editor support for building view criteria for a Bean DC (even if it's model is not backed up by JPA). You may also see the view criteria displayed in data control palette as in case of JPA based Bean DC.  In nutshell,this extension lifts your POJO based bean data control  to the level of JPA based bean DC.

What is the JDev version supported by BeanDCExtension? 
This is built using 12.1.3.0.0 release. 
How to use this extension?
Step 1. Down load the extension
Ste 2: Open JDeveloper 12.1.3.0.0 
Ste 3: Go to Help > Check for Updates. Choose Install From Local File and chose the downloaded extension from step 1 and follow the wizard.
Ste 4: After installing the extension, go to the project where you have the bean data control generated. Right click the project > Project Properties > Libraries and Classpath  and choose Bean DC Extension   as ADF Library.
Ste 5: Open DataControls.dcx source and modify the DataControlHandler attribute in appropriate bean-definition as given below: 
DataControlHandler="com.jobinesh.extension.binding.SimpleBeanDCDataFilterHandler" 
Generate the model xml for the bean or collection(if not done).
You may now start seeing the Named Criteria tab as well in the model xml editor which can be used for building view criteria, and same would appeared in data control palette.
Ste 6:  To give implementation for actual search ,  add a method with following signature in your Java class on which you built data control:
public Object queryByRange(SimpleSearchCriteria searchCriteria) {.....}  in your bean class on which you defined data control. You may want to parse SimpleSearchCriteria  parameter and add the custom search logic here.
     //In your Bean Class
    /**
     * This method needs to be defined in the class that you chose for  building bean data control
   * This method is invoked while querying using af:query component backed up by Criteria
     * (defined on the sparse xml)and pagination.
     * */
    public Object queryByRange(SimpleSearchCriteria searchCriteria) {
     

        /**
        * Handles the Count query triggered by framework. For
* example framework uses this to size table scroll bar
        */
        if (searchCriteria.isCountQuery()) {
   //Implement getTotalCount() by filtering based on searchCriteria
            //searchCriteria.getBeanName() gives the name of the bean
            return getTotalCount(searchCriteria)
        }
        /**
         * Return List of objects that matches searchCriteria object,
*e.g: for return object  List
* searchCriteria.getBeanName() gives the name of the bean
         */
        return getResultList(searchCriteria);
    }




Comments