Complex datatypes for ADF AM/VO client service methods
JDev: 12.2.1.3.0
Source: GitHub
One very recent work-related requirement was to
pass and return complex data types from an Application Module Implementation
class method.
For those of us who are familiar with this
concept, we know that we usually pass around native Java data-types, like
String, Integer, Boolean, etc, or maybe List, Map. But what if we need to pass
and return a complex POJO - such as an Employees object (as shown
below)?
You might have also noticed that we are
able to pass and return oracle.jbo.Row objects. But JDev does not allow us to create a service method if we
want to return a view object's implementation class, such as EmployeesVORowImpl.
The
reason that AM client service implementation allows certain data-types is that
those data-types are available to both Model and ViewController projects. If
you open up Model or ViewController project properties and search for
oracle.jbo.Row class, you will find that it is included inside the 'ADF
Model Generic Runtime' library, which is available to both projects.
So, in order to allow a user class to be
available to both projects, and to preserve MVC principles, we need to create a
new project inside our workspace and create the shared classes in that.
The current application is built on JDev
12.2.1.3.0, and HR schema. But this concept applies to any version of ADF. This
is more to do with the way you set your application up, and less about ADF.
Add a dependency for this project to both Model
and ViewController projects. And that is all that you need to do. Now both
projects are aware of a class named Employees!
You create your AM's implementation class, and
add a method which accepts an Employees object, modifies it and returns
the same to the ViewController bean.
The same client method can be exposed
as a method binding on any page or fragment. The method binding gets created as
follows:
And that's it. Now you have your own
class which can be modified and passed around.
Cheers!
Comments
Post a Comment