Problem with null values returned from extended VO object
Hello, I need some help with an OA extension in the Sourcing module. I want to add an additional column in a table region within a standard OA web page. This table is defined as an own region, and this region is among some other regions added to the main page. The column I want to add is a comment field, which gets data from a database table independent of the rest of the application. I am using JDeveloper to make the extensions.
I have analyzed what to change, and the structure is as follows:
The table region is an xml file, which has its own controller class. All the attributes in this page have the same VO object as their view instance. This VO object contains one EO object, which again extends another EO object. The VO object also contains a query, which is executed with joins to match item IDs with header IDs. The VO object is included in the module’s AM object.
I have made my own database table, with columns to store the ID values used for matching in the VO object, in addition to a column which is supposed to contain the comments as regular string values. I have made my own EO object, completely independent from the standard EO objects. This EO object have all the attributes from my table included. To include my EO object in the VO object, I have made my own VO object that extends the standard VO object. I have included the same EO object which was included in the standard VO object, in addition to including my own EO object. The query is modified to include one extra attribute, and the ID values are joined with my table. I have tested the query in TOAD, and the output is as expected. I have made my own Java controller class, which extends the standard controller class of the given page region. I have changed the controller class field of the page to point to my controller class. I have tested that my own class is run during execution of the page. I have added an item to the page region, which points to the standard VO object (not my own, because I have read in other forum threads that this is the right way to do it). The view attribute field contains my new text field attribute from my own VO object. The field is correctly shown when the page is loaded. To get access to my own VO object, I found it necessary to make my own AM object which extends the standard AM. I have read that this can be done without any problems as long as the given AM is not a root AM. I have included my own VO object in the new AM. The application works fine after these substitutions, and all the old values are displayed as before. Now, I have the following problem:
I want to display the value of the comment field in the newly created column of the table. But from where do I get the data? I suppose the point of doing the join in the VO query is to get the data from the database directly when the page is executed. It is not an easy task to use the code from the old VO and AM objects to understand how this is done for the old objects, as the AMImpl file contains beyond 5000 lines of code and run the set-methods in the VORowImpl class based on a lot of boolean flags, which again are set by values returned by other VO classes that I do not want to change. The other values of the table are set by calling setAttributeInternal(index, value), where each value is returned from getAttributeInternal(index) methods in the VORowImpl class that contains header information (a different VO object). I suppose I have to create a new EO object, which can be used to run my get-method to return the text value from the database. But how do I create this object? And after that, do I have to run the set-method in the EO object to set the attributeInternal value? If that is the case, where do I get this value from? Is attributeInternal the local value of the Java object, or is it the database value?
I have found some documentation in the OA Framework Developer’s Guide, which describes the procedure of making an EO object as follows:
To create an entity object, you must call createRow and then insertRow on the corresponding view object as illustrated below.
// In the application module; this example from the OA Framework
// ToolBox Tutorial will instantiate a SupplierEOImpl.
public void create()
{
OAViewObject vo = getSuppliersVO();
vo.insertRow(vo.createRow());
// Always call this after you perform a row insert. See the Entity Object
// New / Initial section below for additional information.
vo.setNewRowState(Row.STATUS_INITIALIZED);
}
The view object createRow() method calls the create() method on the underlying entity object.
My auto generated EOImpl class has a create() method, which take an AttributeList as argument. But I do not want to create a new row, the rows in the table are created by the methods in the old AMImpl class. I just want to run my get-methods in my EO object to get the values from my own database table, and extend the existing rows with my new text field. All my getAttributeInternal(index) in the VORowImpl class just return null when they are invoked. I hope that I do not have to do all the operations that the old VO object does, because this involve a lot of other VO objects and rowIterators returned by classes that I do not have access to change.
For testing supposes, I have created a callable statement in my VORowIml class and executed a query to the database. The text values are returned. If i run the setAttributeInternal method with the value returned from my query, the text values are correctly displayed on the page. But this is not the way to do it, as all values should be retrieved through the get and set methods of the given RowImpl class. But since these methods just return null, I do not have any ideas how this can be done.
Any tips regarding this matter will be helpful, as I clearly have missed some important points of the extension tools provided by JDeveloper.