Showing posts with label ADFbc ViewObject. Show all posts

gravatar

Adding a dynamic where clause using named bind variables

The following piece of code is used to set a dynamic where clause to a view object. It also shows how to set  values to the named bind parameters present in the dynamic where clause.

    public void addWhereClauseWithNamedBindParams(){
        ViewObject vo=this.getEmp1();
       
      
        vo.setWhereClause(null);
       
        vo.setWhereClause("Empno=:eNo");
        vo.defineNamedWhereClauseParam("eNo",new Integer("7369"),null);
        vo.executeQuery();
       
        vo.removeNamedWhereClauseParam("eNo");
        vo.setWhereClause(null);
    }

gravatar

Adding a dynamic where clause using positional parameters

The following piece of code shows how to add a dynamic where clause to a view object .
It also shows how to set the bind parameters (using the positioning style not the named bind parameters)

    public void addWhereClause(){
        ViewObject vo=this.getEmp1();
       
        vo.setWhereClauseParams(null);
        vo.setWhereClause(null);
       
        vo.setWhereClause("Empno=:1");
        vo.setWhereClauseParam(0,new Integer("7369"));
        // you can also use the following code to set the positional parameters.
        // vo.setWhereClauseParams(new Object[]{new Integer("7369")});
        //
        // The difference between the two apis is that one explicitly provides
        // the bind parameter position and in the second one the position is implicity
       
        vo.executeQuery();
       
        vo.setWhereClauseParams(null);
        vo.setWhereClause(null);
    }

Using the "setWhereClauseParam" or "setWhereClauseParams" api's you cannot set the named bind parameters....

gravatar

Accessing Custom Propeties of Entities

BC4J allows custom properties to be associated to each entity/view object. This can be done declaratively using the overview editor of each object.

To access the value of a custom property (either translated one or the non-translated one), use the following piece of code..

Accessing the custom property value from an entity class

this.getEntityDef().getProperty("propertyName");

The "propertyName" is the name of the property whose value is needed. The property can also be a translatable property. If the property is a translatable property, the above piece of code will fetch the translated value of the LocaleContext associated to the session of the application module..

If the translated value of some other LocaleContext is required then use the following piece of code.

this.getEntityDef().getProperty("propertyName", localeContextObject);

where "localeContextObject" is a java object of type oracle.jbo.LocaleContext.

Accessing the custom property value in viewobject class

In the Impl class just use the method "getProperty"..This takes the same parameters as explained above..