Skip to main content

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:

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 release. 
How to use this extension?
Step 1. Down load the extension
Ste 2: Open JDeveloper 
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: 
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);


Popular posts from this blog

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…