Friday, September 3, 2010

Auto Generated Key in Entity Object

Here by this post I am sharing information about how to set auto generate key for entity object.


Below are the steps:

  • Create a Fusion Web Application.
Select the model project and perform following steps:
  • Create a Business Components from Table, Select Employees table for Entity Object.
  • Create the view updatable view object for Employees View Object.
  • Create Read only view for Department and Jobs.
  • Define list of values for Manager Id, Job and Department Id in Employees View.
  • In Employees View Object set the EmployeeId updatable to never.
  • Open the Employee view object into editor, Select the Java Option then click on the edit button.

  • Select the above option on Java Option popup. It will generate the EntityImpl class for Employees Entity With the selected methods.
  • Open the EmployeesImpl.java file --> goto the create methods.
Edit that method with following code
    /**
     * Add attribute defaulting logic in this method.
     * @param attributeList list of attribute names/values 
     * to initialize the row
     */
    protected void create(AttributeList attributeList) {
        super.create(attributeList);
        SequenceImpl seqImpl = new SequenceImpl("EMPLOYEES_SEQ",
                  getDBTransaction());
        Number num = seqImpl.getSequenceNumber();
        setEmployeeId(num);
    }

Now select the ViewController project and perform following steps:
  • Create a jspx page.
  • Drag and drop view object and create ADF form and table.
  • Drag and drop all the operation like Create Insert, Commit and Rollback to page for creating record, saving it to database.
  • Final steps to run your application. 
  • Once you click on the Create Insert button form will appear blank with new employee id. 

  • Enter data and save it to database.

You can find running workspace from AutoGeneratedKeyForEOSample.zip 

Monday, August 30, 2010

How to use Bounded Task Flow in Application





1.     Create Application



2.     Create Business Components from Tables.

1.         Select the Model project right clicks on the project go to à New à Business tier à ADF business components àBusiness Components using Tables.











10.     Select all Entity Object from the view project  right click à Refractor à move and enter the package name like

15.     Open the View Object go to à Entity Object section it will show no entity object used for read-only view.

16.     Open the view object and go to à Attributes click on the edit button 




3.     Create the create web page:

In this section we will see how to create the taskflow and WebPages.

Here are the steps to create a web page and the task flow.

3.1.   Go to New à Current Project technologies àWeb tier à Jsff àJsf page.



3.2.   Enter the page name as mainPage.jspx and Enter MainPage for manage bean name and class name.

3.3.   Select the page template as Oracle Dynamic Tabs Shell.

3.4.   Create a jsff page with the name of searchPage.jsff inside the fragments package. 


3.5.   Edit Employee Readonly view object and add a search criteria.


3.6.   Drag and drop the search criteria as ADF Query with panel. 

3.7.   Surround with your table with panel collection.

3.8.   Give width for panel collection 100% and change the result id of query control to panel collection.

4.     Create the Task Flow:

In side this section we will how to create the bounded taskflow.

4.1.   Select the view controller project and create the taskflow using New à Web Tier à ADF Task Flow 

4.2.   Enter the taskflow name as EmployeeSearchTaskFlow.xml and place it inside web-inf project.

 

 

4.3.   Drag and drop your jsff page to taskflow.

4.4.   Now your taskflow is ready for use.

5.     Design main page:

As discuss we have created the bounded taskflow, it will require landing page to run. In this section of document we will learn how to create the landing page.

5.1.   For loading the task flow to a page dynamically TaskFlowLoader class is require. Create a java class using.



        5.2   Enter the class name as TaskFlowLoader and package name as com.bss.view.
          package com.bss.view;
          import javax.faces.event.ActionEvent;
          import oracle.ui.pattern.dynamicShell.TabContext;
          /*
           
          * This class is used for loading the taskflow instance programatically to Oracle Dynamic UI Shell           
          Template.
                     
          * */
          public class TaskFlowLoader {
              public TaskFlowLoader() {
                  super();
              }
              /**
               * This method will bind to the link button to load the task flow.
               * @param event
               */
              public void loadSearchTaskFlow(ActionEvent event) {
                  loadTaskFlow("Search Employee Page", "/WEB-          
               INF/EmployeeSearchTaskFlow.xml#EmployeeSearchTaskFlow", false);
              
             }
              private void loadTaskFlow(String title, String taskflowId,
                              boolean newTab) {
                  try {
                      if (newTab) {
                          TabContext.getCurrentInstance().addTab(title, taskflowId);
                      } else {
                          TabContext.getCurrentInstance().addOrSelectTab(title,
                                                               taskflowId);
                      }
                  } catch (TabContext.TabOverflowException toe) {
                      // causes a dialog to be displayed to the user saying that there are
                      // too many tabs open - the new tab will not be opened...
                      toe.handleDefault();
                  }
              }
          }