Tuesday, May 19, 2015

Create application module

Create application module inside the same application source?
We had our transaction managed by the EmpDirectoryModule.xml file. The commit and
rollback operations are a part of the transaction management of the application module.
 
1. With JDeveloper open, locate the Model project and look for the com.
empdirectory.model.am folder. Right-click on this directory and select the
New Application Module option.
2. The package name and the name of the application module can be kept as it is.
3. In the Data Model section, you can select the view object and shuttle to the other
side. We are not doing this also. Click on the Next button.
4. In the next screen, we will move any available application module to the current
one as a child application module. In this case, the root application module will be
maintaining the transaction for the child application module—skip this section also.
5. The next screen can be used to create a Java class for the application module, which we do not need right now.
6. At the end is the summary page, and clicking on the Finish button will create the application module for you.
What just happened?
We have now learnt to create an application module without using the wizard. The application
module is essential for the project, in order to maintain the transaction in a secured way.
The application module that is created can be nested within another application module to
share the transactional information with the parent application module. Application modules
can have Java classes that can override the framework code to bypass the business logic on
commit() and rollback() operations.
Now we are going to add EmpVOToDeptVOLink to the application module to display the master-detail relationship between the EmpVO and DeptVO objects. Adding the view link to the application module will help in retrieving the employees within a particular department.
The following steps show how to add a view link to the application module:
1. Double-click on the EmpDirectoryModule.xml file from com.empdirectory. model.am.
2. Open the Data Model section to select the view object instances.
3. Select the view link accessor for the DeptVO in the Available View Objects: section. In the Data Model section, select DeptVO1 (which is the view object instance name in EmpDirectoryModule).
4. Shuttle the view object to the Data Model section. Now the EmoVO2 object will be added as a child to DeptVO1. This represents the view link association between DeptVO and EmpVO.
5. The instance name for the view link is EmpVO3, in my case.
6. Save the EmpDirectoryModule.xml file:
Business components in action
In this section, we will see how the business components are working at runtime. When we run
the application module, the view object instances that are added to the application module
will be loaded at runtime and the data will be shown to the user, as per the user interaction.
We will run the AM tester using the following steps and see how the components work
in action:
1. Right-click on EmpDirectoryModule and select the Run option from the menu.
2. When the AM tester is ready, click on the view link created. In this case, it will be
EmpVOToDeptVOLink2.
3. This will open records of the ACOUNTING department. You will see that there
are only three employees in this department, from the HRSchema database
we created in Chapter 2, Getting Started with ADF.
source code for this link:
<?xml version="1.0" encoding="windows-1256" ?>
<!DOCTYPE ViewLink SYSTEM "jbo_03_01.dtd">
<!---->
<ViewLink
  xmlns="http://xmlns.oracle.com/bc4j"
  Name="EmpVOToDeptVOLink"
  Version="11.1.2.62.76">
  <Properties>
    <SchemaBasedProperties>
      <LABEL
        ResId="com.empdirectory.model.viewlink.EmpVOToDeptVOLink_LABEL"/>
    </SchemaBasedProperties>
  </Properties>
  <ViewLinkDefEnd
    Name="EmpVO"
    Cardinality="-1"
    Source="true"
    Owner="com.empdirectory.model.view.EmpVO">
    <DesignTime>
      <Attr Name="_accessor" Value="true"/>
      <Attr Name="_finderName" Value="EmpVO"/>
      <Attr Name="_isUpdateable" Value="true"/>
    </DesignTime>
    <AttrArray Name="Attributes">
      <Item Value="com.empdirectory.model.view.EmpVO.Deptno"/>
    </AttrArray>
  </ViewLinkDefEnd>
  <ViewLinkDefEnd
    Name="DeptVO"
    Cardinality="1"
    Owner="com.empdirectory.model.view.DeptVO">
    <DesignTime>
      <Attr Name="_finderName" Value="DeptVO"/>
      <Attr Name="_isUpdateable" Value="true"/>
      <Attr Name="_minCardinality" Value="1"/>
    </DesignTime>
    <AttrArray Name="Attributes">
      <Item Value="com.empdirectory.model.view.DeptVO.Deptno"/>
    </AttrArray>
  </ViewLinkDefEnd>
  <ResourceBundle>
    <PropertiesBundle
      PropertiesFile="com.empdirectory.model.ModelBundle"/>
  </ResourceBundle>
</ViewLink>

No comments:

Post a Comment