programmatic view objects are useful for temporary data storing and processing. i use these view objects mostly when there are third party services that provide complex data types. after getting required data, i programmatically search some info in complex type and insert some of them to programmatic view object.

when processes are getting longer and new requirements are appeared, i call same service (cheap to call in the beginning of project) to get same data in later steps instead of creating new attributes to view object. i know that this is not a best practice but we developers sometimes have this kind of technical debts.

in this post, i will write about custom attribute type for storing complex data types retrieved from -let’s say- services.

first we need a test type which simulates our third party service return type. let’s call it TestType. this is a simple POJO with two fields long field1, String field2. then we need an encapsulating class that implements oracle.jbo.domain.DomainInterface, call it TestTypeDomain. This is how i implement:

private TestType type;
public TestTypeDomain(TestType t1) {
  super();
  this.type = t1;
}
public Object getData() {
  return this.type;
}

and we can add new attribute to programmatic view object.

after some testing code added to application module to fill programmatic view object, following screenshots show how TestType can be used.

and this is jsf fragment page code using TestType fields.

this is not a complete solution. if we work with programmatic view objects, we should think about adf passivation/activation mechanism. i will prepare a post about this soon.

Advertisements