X

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.


Join the discussion

Comments ( 2 )
  • Ram Thursday, June 9, 2011
    The method name in AM is getDeptName but in your expression its getName. Is this a typo?
  • shantala.sankeshwar@oracle.com Thursday, June 9, 2011
    Yes,it was typo.Thanks for pointing & I have renamed that.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.