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.


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