Friday May 20, 2011

How to call a method defined in AppmoduleImpl using groovy expression?

Usecase Description:

Suppose we have a Transient attribute that stores the value returned by an Appmodule method,then the easy way to call this method in transient attribute would be using Groovy expression.

Consider a simple method in AppmoduleImpl java class that returns the Department name of the selected row of Emp table:

 public String getDeptName(Number dno)

    {
        if (dno == null)
            return null;
        else {
            ViewObject vo = findViewObject("DeptView1");

            try {
                Row row =
                    vo.findByKey(new Key(new Object[] { new oracle.jbo.domain.Number(dno) }),
                                 1)[0];

                if (row != null) {
                    Object name = row.getAttribute("Dname");
                    if (name != null)
                        return name.toString();
                    else
                        return null;
                } else
                    return "Specified dept does not exists";
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }

        }
    }
Create an Updatable Transient attribute in EmpView Object.Edit its value & provide a groovy expression "adf.object.applicationModule.getDeptName(Deptno)" to call the above method

Run the AppModule & note that the transient attribute returns the Department name corresponding to the selected row of Emp table.


How to call a method defined in ViewObjectImpl using groovy expression?

Usecase Description:

We can define a transient attribute that calls  ViewObjectImpl.java method using Groovy expression.

Consider a simple method in EmpViewImpl java class that returns the currentRowIndex:

 

  public Number returnCurrentRowIndex()
   {
    return this.getCurrentRowIndex();
   }


Create an Updatable Transient attribute in EmpView Object.Edit its value
& provide a groovy expression "adf.object.viewObject.returnCurrentRowIndex()
" to call the above method

Run the AppModule & note that the transient attribute returns the currentRowIndex of the selected row of Emp table.

Customizing display of components in ADF Libraries

Introduction:

ADF Libraries are Java archive files, from which ADF Components like Business Components, Data controls, taskflows etc can be reused. This data however only lists default names of components. This ariticle deals with cuztomizing metadata visibility in ADF Libraries through the  use of resource bundles.  

Sample Application:

Customizing visibility and component names inside an ADF Library needs two things:

  • A custom Meta-Inf file.
  • A Resource bundle - a .properties file.
The following steps illustrate this feature:

  1. Create a Fusion Web Application and create ADFBC Components based on Dept and Emp tables in the model,
  2. Create a View controller with a bounded taskflow, with 2 view objects - Dept and Emp. Define control flow scope, and create page fragments out of them.
  3. Create an ADF Library deployment profile in the View Controller project.
  4. In the View Controller project create a .properties file - LibraryBundle.properties.



.name=Friendly jar name
.description=Friendly long description of the jar
.tooltip=This is the tooltip text to display on mouse hover
.helptopic=alternateHelpSystemTopicId

ADF_DataControl|model/AppModule.xml.name=Friendly BC DC name

5. Create a custom metainf file in your local system:




Specification-Title: WebCenter ServiceList TaskFlows
Specification-Version: 11.1.1.0.0
Specification-Vendor: Oracle Corp.
Implementation-Version: JDEVADF_MAIN_GENERIC_080316.1855.4913
Implementation-Vendor: Oracle Corp.
Help-Topic: someHelpSystemTopicId
Bundle-Classes: LibraryBundle

6. Save this as Custommetainf.mf. Create a ADF Library deployment profile.

7. Add Custommetainf.mf in the Jar options while creating the deployment profile.

Thumbnail image for jaroptions.PNG



8. Deploy the jar, and create a file system connection to it. Open it in the resource palette.

respalette.PNG


Note that both the Jar names, and the Data control names are both displayed with customized names that were defined in the resource bundles.

About

Tips and Tricks from Oracle's JDeveloper & ADF QA

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today