My Procurement ApplicationJDeveloper Version: 11.1.1.0.0Audience: BeginnersPrerequisites: Oracle JDeveloper 11g, Oracle Da...
REGISTRATION_LINES_S: used to generate registration line id.Database DiagramComplete application along with SQL script can...
http://kohlivikram.blogspot.com/
Registration Page: - This page is used to create the new registration. User willcreate the new registration details and wi...
Field                     Type and Description             Valid valuesRegion:- Registration DetailsRegistration Number   ...
create the registration.    from HR. Employees table.Department Name              Department to which the                 ...
Item List page: - This page will help the user to search a particular item. Userwill navigate to this page from registrati...
http://kohlivikram.blogspot.com/
http://kohlivikram.blogspot.com/
Item Details page:- In this page user will specify the quantity of items to beordered . User will navigate to this page fr...
Chapter 1Creating ADF Workspace & Database Connection1.1 Creating ADF WorkspaceIn the application navigator , right click ...
Install the database object required for this application in default HR schema. Createa database connection with your HR s...
• In the Application Navigator, expand the Connections                               and Database nodes in the Application...
Step 4) In the Create Entity Object class, specify package as “model.entity”, Nameas “RegistrationEO”. And select schema o...
Step 5) Click next up till step 5 and click finish. This finishes the creation of theentity object RegistrationEO.Step 6) ...
Open    the    RegistrationEOImpl     class   and    replace   the   “protected   voidcreate(AttributeList attributeList)”...
In our application in the Registration page, the creation date default value should be‘current system date’ and registrati...
Step 4) Click next until “step 4 of 5” and then click finish.2.3 View Objects required in application :- View objects are ...
CatalogVO – to query the CATALOG table which will be used in the Catalog-categorypage.CategoryVO – to query categories tab...
Step 4) Click next until step 4 of 9 and then click finish.In the same fashion create remaining view objects based on foll...
Employees.JOB_ID,   Employees.SALARY,   Employees.COMMISSION_PCT,   Employees.MANAGER_ID,   Employees.DEPARTMENT_ID,   Emp...
(PFI.PFI_PER*(RegistrationLines.QTY*Item.UNIT_PRICE))/100      asUSD_PFI_AMOUNT,                                (Registrat...
Step 1) Right click the model.view and select “New View Object”.Step 2) In the Create View Object – Step 1 of 9 , specify ...
ITEM.DESCR,   ITEM.UOM,   ITEM.UNIT_PRICE,   ITEM.CURRENCY,   ITEM.MANUFACTURERFROM REGISTRATION_LINES RegistrationLinesEO...
Step 8) Click OK to finish creating the view criteria.Now similarly create the view criteria           named   “ItemListPa...
2.5 List of Values used in ApplicationThere are various LOV components which are used in different pages in ourapplication...
Requested By field in the Registration page shows all the employee name in the dropdown list.Step 1) Select the Registrati...
Step 5) In the “List of values” select “EmployeeId” from “List Attributes”. And theclick OK.Step 6) In the “UI Hints” tab,...
–> create the list of values for the “Category name” attribute based on the“CategoryVO” as “List data source” in the “Item...
2.6 View Links used in the application  View links defines the relationship between the ADF view objects. We need viewlink...
RegistrationV   Registrati RegistrationLin RegistrationP RegistrationP Used in theO               onId       esVO         ...
Step 1) Select the “model.view” node under the “Model-->Application Sources”sources.Step 2) In the “Create View Link – Ste...
EmployeeVO                                                    EmployeesListVOItemListPageVO                               ...
http://kohlivikram.blogspot.com/
Step 4) Click on finish.So you have finished creating the Business service layer using the ADF Businesscomponents. Your mo...
2.8 ValidationsIn the Item Details page, we have a validation that quantity should be greater thenfive. This can be achiev...
Step1 ) Select the RegistrationLinesEO under the model.entity and select the“Attributes”.Step 2) Select the Qty from the A...
We will now work on the controller and user interface for this application. We willstart with building the page template. ...
geometry management component. This means that when user resizes the browser,Panel Stretch layout components will resize i...
http://kohlivikram.blogspot.com/
Now select the Panel Stretch Layout and set following properties in propertyinspector:-StartWidth = 0pxEndWidth = 0pxTopHe...
We have finished creating the page template and now we will proceed to create ourapplication pages. Here is a plan; we wil...
This page will show the catalogs - categories table as master table and inline detailtable and an items table under the ma...
</nodeDefinition>With<nodeDefinition DefName="model.view.CategoryVO">    <AttrNames>      <Item Value="CategoryName"/>    ...
We are done with the process by which the Item table will gets refreshed when theCategory Name link is clicked by user. Bu...
This will generated your AMImpl class where you can write service methods.Step 3) Open your AMImpl class by selecting clas...
Step 6)      In the Edit Action Binding window set parameter value as#{detailRow.CategoryId}.Now set the following propert...
Step 5) In the Edit Table Column delete all columns except “CatalogueName”,”Descrr”, ”CatageoryName”, ”Descr”, ”Product Co...
listener, right click the command link and select the “insert inside af:commandlink-->ADF Core--> Set Action Listener”.Ste...
Step 1) Select the PanelGroupLayout from the layout components and drop it on theSecond facet of above created panelSplitt...
Adding Registration Managed BeanWhen user navigates from the Home page to the Registration page by clicking on the“New Reg...
Action Button Bar RegionStep 1) Select the OperationsCommit from the data control palette and drop it onthe ActionButtonB...
This finishes the layout of the Registration page, our big fish. We will now work withcontroller to define the flow of the...
method in managed bean or application module or calling another task flow. ADFcontroller which is build up using task flow...
Step 6) Select the above created router activity. From the property inspector underthe common node, specify two cases as b...
3.6 Creating Home pageStep 1) Create your home page with name “HomePage” based on the created ADFtemplate we created.Step ...
Step 3) Expand the af:PanelGroupLayout and select af:panelHeader. And set the textproperty =” Search Registration”.Step 4)...
Step 5) From the “Edit Tree Binding” for the “model.view.SearchPageRegistrationVO”,shift all the attributes from available...
Step 11) Convert the output text for registration number to link with text property=#{row.RegNum}Step 12) Inside the Actio...
3.7 Creating Item Details pageSo we are now at final page of our application. We will create this page layout andafter tha...
data as well as navigate to the Registration page, but cancel will just navigate toregistration page. Now in both the comm...
Let’s proceed now with updating page flow so that user can add lines in theregistration.Step 8) Select a method activity f...
Add the above method in the application module client Interface.Step 12) Select the initilizeNewRegLines from the data con...
Step 20) Select the item list page from the application navigator and drop it on theadf-config.xml in the code editor.Step...
//commit();      }  }Expose the above method in the application module client. Now open your EditRegistration page flow, s...
Upcoming SlideShare
Loading in …5
×

13088674 oracle-adf-11g-learning-application-my-procurement-application

1,549 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,549
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
46
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

13088674 oracle-adf-11g-learning-application-my-procurement-application

  1. 1. My Procurement ApplicationJDeveloper Version: 11.1.1.0.0Audience: BeginnersPrerequisites: Oracle JDeveloper 11g, Oracle Database 10g XEBusiness Scenario:I have developed this sample application to learn Oracle ADF 11g.And in thisdocumented you will find the steps for developing this complete sample application.This application manages the procurement activities with in an organization. Thedifferent type of procurement activates handled by this application are:- • Search for the Registrations. • Creating Registration and adding item lines to Registration. • Search item in catalog and categories. • Edit the existing created registration. • Search already created registration.It is best to view this document with View as web layout, whether you are using theMS Word or the Open office Word Editor.Terms Used in Application 1) A Registration is created which can later on used to create purchase order. Users add items in registration. 2) Registration lines are items which are added in registration. 3) Catalog contain categories. 4) Categories contain items. 5) PFI is package, fright and insurance charges.Following database objects are used in this application:-CATALOG: - database table which stores catalog details.CATEGORY: - database table used to store various categories of a catalog.ITEM: - database table used to store item belongs to different categories.PFI_DETAILS:- database table used to store Packaging, Freight and Insurancepercentage based on the mode of payment of the item.REGISTRATION: - database table used to store registration created by users.REGISTRATION_S: sequence used to generated registration idREGISTRATION_LINES:- database table used to store goods which are added toregistration.http://kohlivikram.blogspot.com/
  2. 2. REGISTRATION_LINES_S: used to generate registration line id.Database DiagramComplete application along with SQL script can be download fromhttp://www.4shared.com/file/91772443/17828aab/MyADFLearningApp.htmlScreen details: - We have following screens in this application.Home page: - Allows user to search for the registration. Search page where usercan search for the already created registrations and can navigate to the registrationpage to update the registration and add new registration lines in the registration.User can create the new registration by clicking the “New Registration” button on thispage.http://kohlivikram.blogspot.com/
  3. 3. http://kohlivikram.blogspot.com/
  4. 4. Registration Page: - This page is used to create the new registration. User willcreate the new registration details and will edit the existing registration details.Following are field details for the page.http://kohlivikram.blogspot.com/
  5. 5. Field Type and Description Valid valuesRegion:- Registration DetailsRegistration Number Unique registration number.Procurement Type Static List of values Standard Procurement, Emergency and Reimbursable ProcurementRegistration status Static List of values Open ,ClosedUrgency Static list of values Normal , UrgentTotal USD Amount Sum of Total USD amount of the added lines in the registrationTotal PFI Amount Sum of Total PFI amount of the added lines in the registrationRegion:- Creation DetailsCreated By Name of the user who created itCreation date Date of creationRequested by User who requested to Full name of employeeshttp://kohlivikram.blogspot.com/
  6. 6. create the registration. from HR. Employees table.Department Name Department to which the user who requested the registrationRegion :- Registration LinesDetails of the line added tothe registration along withediting the line anddeleting the line columnsCatalog Categories Page: - This page contains two regions:-Catalog-category region:- contains catalog table which has categories as its innertable .Items region:- shows the item under the categories.When user clicks on a particular category name, Item table gets refreshed to showall items under that category. This is achieved using the PPR functionally. User willnavigate to this page when he clicks on the “Add Item” button on the “Registrationpage”. On this page, “Search Item” will navigates to “Item list page” and “backbutton“ will take us back to “Registration page”.http://kohlivikram.blogspot.com/
  7. 7. Item List page: - This page will help the user to search a particular item. Userwill navigate to this page from registration page and catalog page after clicking on“Search Item “button.http://kohlivikram.blogspot.com/
  8. 8. http://kohlivikram.blogspot.com/
  9. 9. http://kohlivikram.blogspot.com/
  10. 10. Item Details page:- In this page user will specify the quantity of items to beordered . User will navigate to this page from Catalog categories page and Item listpage after clicking on product code. Clicking on the button “Add to Registration” willadd the current item from this page with specified quantity to the currentregistration. Here the quantity specified should always be greater then or equal to 5.Application Flow :-http://kohlivikram.blogspot.com/
  11. 11. Chapter 1Creating ADF Workspace & Database Connection1.1 Creating ADF WorkspaceIn the application navigator , right click and select “New Application to create a newApplication based on “Fusion web application(ADF)” in your Jdeveloper 11g. Acceptall other setting as it is and click finish.http://kohlivikram.blogspot.com/
  12. 12. Install the database object required for this application in default HR schema. Createa database connection with your HR schema.1.2 Creating a Database Connection Open the Create Database Connection dialogue [File > New > General > Connections > Database Connection] . • Select Application Resources if it is not selected as the Create Connection In option. • Enter a name for the connection, select the connection type, and enter the username and password. • Click Test Connection to confirm that you can connect. • Click OK if the connection was successful.http://kohlivikram.blogspot.com/
  13. 13. • In the Application Navigator, expand the Connections and Database nodes in the Application Resources panel to see the database objects.Chapter 2Creating Business Service Layer Objects :-In this learning application, I am using ADF business components previously knowsas BC4J to build our business services layer. Business services components acts as acommunication channel between between an MVC application and a data source(usually a database). This components implements the O/R mapping and businessrules/validations.21. Entity Objects required in application :- An entity object is a businesscomponents maps to a single object in the data source. It includes data,businessrules and persistence behavior for database tables used in your application. Eachdatabase column of a table is represented as attribute in entity object. In myapplication user is storing data in two tables :-→ in REGISTRATION table through registration page where user creates/edit newregistration.→ in REGISTRATION_LINES table through item details page where user add/editquantity.For more conceptual knowledge on entity objects hitwww.oracle.com/technology/documentation/jdev/adf_guidelines_manual.pdfand read Chapter 3, ADF Business Components in Depth.So we will create two Entity objects based on above two tables with nameRegistrationEO and RegistrationLinesEO.Steps to create RegistrationEOStep 1) Right click on the Model project and select New.Step 2) In the “New Gallery” window under “Business Tier” select “ADF BusinessComponents”.Step 3) Select “Entity Object” from Items and click OK.http://kohlivikram.blogspot.com/
  14. 14. Step 4) In the Create Entity Object class, specify package as “model.entity”, Nameas “RegistrationEO”. And select schema object as “REGISTRATION”.http://kohlivikram.blogspot.com/
  15. 15. Step 5) Click next up till step 5 and click finish. This finishes the creation of theentity object RegistrationEO.Step 6) Generating Entity object java class for custom functionality:-We need to set the RegistrationId value which comes up from the “Registration_S”database sequence when new registration is created. Double click RegistrationEOfrom the application navigator window and select java option from the code editorwindow. Click on the Edit Java Option icon and in the “Select Java Option window,check the “Generate Entity Object Class”, “Accessors” and “Create Method” checkboxes and click ok. Check out following figure for helphttp://kohlivikram.blogspot.com/
  16. 16. Open the RegistrationEOImpl class and replace the “protected voidcreate(AttributeList attributeList)” method add following code import oracle.jbo.server.SequenceImpl; protected void create(AttributeList attributeList) { super.create(attributeList); SequenceImpl s = newSequenceImpl("REGISTRATION_S",getDBTransaction()); Number seqNum=s.getSequenceNumber(); setRegistrationId(seqNum); setRegNum("MP" + seqNum); }This create method is called when you insert a new row inside your entity object.This method can be used to initialize default values for the first time entity row iscreated.Step 7) Set up default values for Attributeshttp://kohlivikram.blogspot.com/
  17. 17. In our application in the Registration page, the creation date default value should be‘current system date’ and registration status field default value should be ‘Open’.Select the Attributes tab from the code editor window and select “Creation Date”attribute. Double click it and in the “Edit Attribute” window, check the history columncheck box and select “created on” from drop down and click ok.Again double click the “RegStatus’ attribute and in the “Edit Attrbute” window set thevalue = ‘Open’.Select the ‘ProcType’ attribute and check the Mandatory check box to make this fieldrequired in the UI.Steps to create RegistrationLinesEOIn a similar fashion you can create entity object RegistrationLinesEO. And add thefollowing create method in the RegistrationEOImpl classprotected void create(AttributeList attributeList) { super.create(attributeList); SequenceImpl s = newSequenceImpl("REGISTRATION_LINE_S",getDBTransaction()); Number seqNum=s.getSequenceNumber(); setLineId(seqNum); }2.2 Creating Entity Association :- Entity association defines the relationshipbetween two entity objects based on entity attributes. Associations often map toforeign key relationships between tables in the database. As in our SQL script wehavent defined any foreign key constraints, we have to manually define theassociation between these two entity objects. If the foreign key relation ship exist atdatabase level , ADF framework will itself create the association. Association allowyou to navigate from one entity instance to either another entity instance or acollection of related instances.For more conceptual knowledge on association hithttp://www.oracle.com/technology/oramag/oracle/05-nov/o65frame.html?_template=/ocom/printStep 1) Right click the model.entity node and select “New Association”.Step 2) Specify package as “model.entity.assoc” and Name as RegLinesAO”.And clicknext.Step 3) Select “RegistrationId” under RegistrationEO from “Select Source Attribute”and “RegistrationId” from “RegistrationLinesEO” under “Select Destination Attribute”.And click on add button.http://kohlivikram.blogspot.com/
  18. 18. Step 4) Click next until “step 4 of 5” and then click finish.2.3 View Objects required in application :- View objects are ADF businesscomponents that collects data from the database based on the SQL query. SQL querycolumns map to view attributes in the view object . A view object are either :-Entity based which means view attributes are mapped to entity object attributes .SQL based also know as Read only View Objects which are not mapped to entityattributes.Thought we can create multiple UI pages based on the same view object, I think weshould create separate view object for individual page because application will bemore maintainable.We create read only view object for UI pages which only shows data and entity basedview objects for pages which perform DML operations on data. For our application,we will create following view objects :-2.3.1 Read only view objectshttp://kohlivikram.blogspot.com/
  19. 19. CatalogVO – to query the CATALOG table which will be used in the Catalog-categorypage.CategoryVO – to query categories table which will be used in the Catalog-categorypage.EmployeesVO – will be used in drop down “Requested By” field in the Registrationpage.ItemListPageVO – will be used in the Item list page.ItemVO – to be used to get the item details based on the product code from the Itemtable. Will be used in the Item details page to set the new row data based on datafetched by this view object.RegistrationLinesVO – will be used in the registration page to show the lines details .SearchPageRegistrationVO – will be used in the Home page.SearchPageRegistrationLinesVO – will be used in the home page to show the linesthat exist in the already existing registration.Steps to create the CatalogVOStep 1) Select model node, right click and select “New View Object”.Step 2) In the Create View Object window, specify package name as “model.view”and name as “CatalogVO”. And select “read only access through sql query” radiobutton.Step 3) In query window of step 2 of 9 , specify following query :-SELECT CATALOG.CATALOGUE_ID CATALOGUE_ID, CATALOG.CATALOGUE_NAME CATALOGUE_NAME, CATALOG.DESCRR DESCRRFROM CATALOGand set Order by as "CATALOGUE_NAME"http://kohlivikram.blogspot.com/
  20. 20. Step 4) Click next until step 4 of 9 and then click finish.In the same fashion create remaining view objects based on following queries:-CategoryVOSELECT Category.CATEGORY_ID, Category.CATALOGUE_ID, Category.CATEGORY_NAME, Category.DESCRFROM CATEGORY CategoryEmployeesVOSELECT Employees.EMPLOYEE_ID, Employees.FIRST_NAME, Employees.LAST_NAME, Employees.EMAIL, Employees.PHONE_NUMBER, Employees.HIRE_DATE,http://kohlivikram.blogspot.com/
  21. 21. Employees.JOB_ID, Employees.SALARY, Employees.COMMISSION_PCT, Employees.MANAGER_ID, Employees.DEPARTMENT_ID, Employees.First_NAME || || LAST_NAME FULL_NAMEFROM EMPLOYEES EmployeesItemListPageVOSELECT CATALOG.CATALOGUE_ID CATALOGUE_ID, CATALOG.CATALOGUE_NAME CATALOGUE_NAME, CATALOG.DESCRR DESCRR, CATEGORY.CATEGORY_ID CATEGORY_ID, CATEGORY.CATALOGUE_ID CATALOGUE_ID1, CATEGORY.CATEGORY_NAME CATEGORY_NAME, CATEGORY.DESCR DESCR, ITEM.PRODUCT_CODE PRODUCT_CODE, ITEM.CATEGORY_ID CATEGORY_ID1, ITEM.DESCR DESCR1, ITEM.UOM UOM, ITEM.UNIT_PRICE UNIT_PRICE, ITEM.CURRENCY CURRENCYFROM CATALOG, CATEGORY, ITEMWHERE CATEGORY.CATALOGUE_ID = CATALOG.CATALOGUE_ID AND ITEM.CATEGORY_ID= CATEGORY.CATEGORY_IDItemVOSELECT Item.PRODUCT_CODE, Item.CATEGORY_ID, Item.DESCR, Item.UOM, Item.UNIT_PRICE, Item.CURRENCY, Item.ManufacturerFROM ITEM ItemRegistrationLinesVOSELECT RegistrationLines.LINE_ID, RegistrationLines.PRODUCT_CODE, RegistrationLines.QTY, RegistrationLines.REGISTRATION_ID, Item.UNIT_PRICE, Item.CURRENCY , RegistrationLines.QTY*Item.UNIT_PRICE as USD_AMOUNT ,http://kohlivikram.blogspot.com/
  22. 22. (PFI.PFI_PER*(RegistrationLines.QTY*Item.UNIT_PRICE))/100 asUSD_PFI_AMOUNT, (RegistrationLines.QTY*Item.UNIT_PRICE) + ((PFI.PFI_PER*(RegistrationLines.QTY*Item.UNIT_PRICE))/100) asUSD_TOTAL_AMOUNTFROMREGISTRATION_LINES RegistrationLines,Item,PFI_Details PFIWHERERegistrationLines.PRODUCT_CODE=Item.PRODUCT_CODE(+) ANDItem.MODE_OF_PAY=PFI.MODE_OF_PAY(+)SearchPageRegistrationVOSELECT Registration.REGISTRATION_ID REGISTRATION_ID, Registration.REG_NUM REG_NUM, Registration.REG_STATUS REG_STATUS, Registration.TOTAL_USD_AMT + Registration.TOTAL_PFI_AMTTOTAL_USD_PFI_AMOUNT, Registration.CREATION_DATE CREATION_DATEFROM RegistrationSearchPageRegistrationLinesVOSELECT REGISTRATION_LINES.REGISTRATION_ID REGISTRATION_ID, REGISTRATION_LINES.LINE_ID LINE_ID, REGISTRATION_LINES.PRODUCT_CODE PRODUCT_CODE, REGISTRATION_LINES.QTY QTY, ITEM.UOM UOM, ITEM.CURRENCY CURRENCYFROM REGISTRATION_LINES,ITEMWHEREREGISTRATION_LINES.PRODUCT_CODE = ITEM.PRODUCT_CODEORDER BY "LINE_ID"2.3.2 Entity based view objectsRegistrationVO - will be used in the Registration page as new registration is createdand existing are modified. This view object will be based on RegistrationEO entityobject.ItemDetailsVO – will be used in the Item Details page as new items are added toregistration and existing are modified. This view object will be based onRegistrationLinesEO entity object.Steps to create the RegistrationVOhttp://kohlivikram.blogspot.com/
  23. 23. Step 1) Right click the model.view and select “New View Object”.Step 2) In the Create View Object – Step 1 of 9 , specify the Name as“RegistrationVO”.Step 3) In Step 2 of 9, from the Available list, select RegistrationEO from themodel.entity and shift it to the Selected area.Step 4) In step 3 of 9, shift all the attributes from available list to the selected listand click next.Step 5) Click next again, and in the “Step 5 of 9” select “Expert” as SQL mode andpaste the following query in the Query statement.SELECT RegistrationEO.CONSIGNEE_ID, RegistrationEO.CREATED_BY, RegistrationEO.CREATION_DATE, RegistrationEO.LAST_UPDATED_BY, RegistrationEO.NOTES_BUYER, RegistrationEO.PARTY_NOTES, RegistrationEO.PROC_TYPE, RegistrationEO.REG_NUM, RegistrationEO.REG_STATUS, RegistrationEO.REGISTRATION_ID, RegistrationEO.REQUESTED_BY, RegistrationEO.SHIPING_ID, RegistrationEO.TOTAL_PFI_AMT, RegistrationEO.TOTAL_USD_AMT, RegistrationEO.URGENCY, Emp1.FIRST_NAME || || Emp1.LAST_NAME LAST_UPADTED_NAME, Emp2.FIRST_NAME || || Emp2.LAST_NAME CREATED_BY_NAME, Emp3.FIRST_NAME || || Emp3.LAST_NAME CONSIGNEE_NAME, Emp4.FIRST_NAME || || Emp4.LAST_NAME SHIPPING_NAME, Emp5.FIRST_NAME || || Emp5.LAST_NAME REQUESTED_BY_NAME, Dept.Department_nameFROM REGISTRATION RegistrationEO, EMPLOYEES Emp1,EMPLOYEESEmp2,EMPLOYEES Emp3,EMPLOYEES Emp4,EMPLOYEES Emp5,DEPARTMENTS deptWHERE RegistrationEO.LAST_UPDATED_BY = Emp1.EMPLOYEE_ID(+)AND RegistrationEO.CREATED_BY = Emp2.EMPLOYEE_ID(+)AND RegistrationEO.CONSIGNEE_ID = Emp3.EMPLOYEE_ID(+)AND RegistrationEO.SHIPING_ID = Emp4.EMPLOYEE_ID(+)AND RegistrationEO.REQUESTED_BY = Emp5.EMPLOYEE_ID(+)AND Emp2.Department_id=Dept.Department_id(+)and click finish .Similarly create the ItemDetailsVO based on the RegistrationLinesEO with followingquerySELECT RegistrationLinesEO.LINE_ID, RegistrationLinesEO.PRODUCT_CODE, RegistrationLinesEO.QTY, RegistrationLinesEO.REGISTRATION_ID,http://kohlivikram.blogspot.com/
  24. 24. ITEM.DESCR, ITEM.UOM, ITEM.UNIT_PRICE, ITEM.CURRENCY, ITEM.MANUFACTURERFROM REGISTRATION_LINES RegistrationLinesEO,ITEMWHERE RegistrationLinesEO.PRODUCT_CODE=ITEM.PRODUCT_CODE.2.4 View Criteria used in applicationA view criteria defines filter information for the rows of a view object collection. Wedefined view criteria because they will be used in the search pages we will create forour application. In our application, we have two search pages, Home page whichallows to search the already created registration. And the Item list page which allowsto search the existing item. For home page, we are using SearchPageRegistrationVOand for Item list page, we will use ItemListPageVO. So we will create the view criteriaon both of these view objects.Creating View Criteria on SearchPageRegistrationVO view object.Step 1) Double click on the SearchPageRegistrationVO.Step 2) In the overview editor navigation list, select Query and expand the ViewCriteriasection.Step 3) In the View Criteria section, click the Create New View Criteria icon.Step 4) In the Create View Criteria, specify the name of the view criteria asSearchPageRegistrationVOCriteria.Step 5) In the Query Execution Mode drop down list, select Both.Step 6) Click on “Add Group” button because our view criteria will be based multiplecriteria items.Step 7) Add registration number,registration status, total USD PFI amount andcreation details as items under the created group as depicted in following diagram:-http://kohlivikram.blogspot.com/
  25. 25. Step 8) Click OK to finish creating the view criteria.Now similarly create the view criteria named “ItemListPageVOCriteria” onItemListPageVO with following criteria items.http://kohlivikram.blogspot.com/
  26. 26. 2.5 List of Values used in ApplicationThere are various LOV components which are used in different pages in ourapplication. In ADF 11g we define List of values against the VO attributes which aregoing to be displayed as LOV in the UI. This a I think one of the great features thathas came up in ADF 11g as we are setting the LOV at the model layer itself. In thislearning application, LOV is used in the→ Registration page for the requested by field which will show the employees in thedrop down list .→ And in the Item list page for the Catalog and Category fields in the search region.Steps to set the “Requested By” field in registration page as LOVhttp://kohlivikram.blogspot.com/
  27. 27. Requested By field in the Registration page shows all the employee name in the dropdown list.Step 1) Select the RegistrationVO from the model.view package.Step 2) In the code editor window , select the Attributes tab. And then select the“RequestedBy” attributes.Step 3) In the “List of Values: RequestedBy” , click on the new LOV icon(a greencolor one)Step 4) In the “List of Values” window, click on the new “List Data Source”. “ViewAccessors” window will appear. In this window select the “EmployeeVO” under“model.view” from the “Available View Object” and shift to the “View Accessors” list.And then click OK.http://kohlivikram.blogspot.com/
  28. 28. Step 5) In the “List of values” select “EmployeeId” from “List Attributes”. And theclick OK.Step 6) In the “UI Hints” tab, select and shift “Full Name” from “Available” to“Selected” list.In the same fashion→ create the list of values for the “Catalog name” attribute based on the “CatalogVO”as “List data source” in the “ItemListPageVO”. In “UI Hints” select appropriateattributes to be displayed in LOV. Refer following figure to achieve thishttp://kohlivikram.blogspot.com/
  29. 29. –> create the list of values for the “Category name” attribute based on the“CategoryVO” as “List data source” in the “ItemListPageVO”. In “UI Hints” selectappropriate attributes to be displayed in LOV. Refer following figure to achieve thishttp://kohlivikram.blogspot.com/
  30. 30. 2.6 View Links used in the application View links defines the relationship between the ADF view objects. We need viewlinks to create the master detail components in the user interface. In ourapplication, we need to create the view link between following view objects.Source View Source Destination Destination View Link DescriptionObject View View Object View name Attribute AttributeSearchPageRe Registrati SearchPageRe RegistrationI HomePageVL Used in thegistrationVO onId gistrationLines d home page VO to show the master detail relationship as table between table for registration and its lines.http://kohlivikram.blogspot.com/
  31. 31. RegistrationV Registrati RegistrationLin RegistrationP RegistrationP Used in theO onId esVO ageVL ageVL registration page to link the RegistrationV O and RegistrationL inesVOCatalogVO Catalogue CategoryVO CatalogueId CatalogCate Used in the Id goryVL Catalog- Category page to achieve the master detail relationship as table with in table where outer table shows Catalog and inner table shows categories within that table.CategoryVO CategoryI ItemListpageV CategoryId1 CategoryIte Used in the d O mVL Catalog- Category page, when user select the category from inner table, the item table gets refreshed with relevant items for that category.RegistrationV Registrati ItemDetailsVO RegistrationI ItemDetailsV To link theO onId d L ItemDetailsV O and RegistrationV OSteps to create the view link HomePageVLhttp://kohlivikram.blogspot.com/
  32. 32. Step 1) Select the “model.view” node under the “Model-->Application Sources”sources.Step 2) In the “Create View Link – Step 1 of 7 “, set the package to“model.view.link” and name to “HomePageVL”. And click next”.Step 3) In step 2 of 7, select “RegistrationId” in “SearchPageRegistrationVO” under“select source Attribute” . And select “RegistrationId” in“SearchPageRegistrationLinesVO” under “Select destination Attribute”. And then clickon the “Add”. Click “OK” and then click finish.In a similar fashion, create other view links.2.7 Application moduleApplication module are business components that→ provide data required by application to complete the specific task .The applicationmodule data model contains view object and view link instance. A view objectinstance manages a single cache of retrieved data. And view link instance provides amaster-detail relationship between view object instances.→ provides access to the transaction object. A transaction object maintains pointersto entity and view caches; it maintains a database connection; and it is responsiblefor post, commit, and rollback operations.→ let developer define the service methods which are defined in the applicationmodule class. These service methods allows you to dynamically add/remove newview objects to data model at run time and to perform operations on the view cacheresult set.In completing the business service layer objects, we will create the applicationmodule and will add the view objects to the application module. Following steps willhelp you to create this:-Step 1) Select the model node, right click and select “New Application Module”.Step 2) In Step 1 of 5 , package name should be model and name should beMyLearningAM. And click on next.Step 3) In step 2 of 5, we will add the view objects and view links in the data model.From the “Available View Object” pane select the following view objects under“mode.view” and shift it to the ”Data Model” pane.View Object to be selected under “Available View “New Instance Name” to be specified.Objects”CatalogVO CatalogPageVOCategoryVO via CataloeCategoryVL CatalogCategoryVOItemListPageVO CatalogeCategoryItemVOCatalogVO CatalogListVOCategoryList CategoryListVOhttp://kohlivikram.blogspot.com/
  33. 33. EmployeeVO EmployeesListVOItemListPageVO ItemListPageVOItemVO ItemListVORegistrationPageVO RegistrationPageVORegistrationLinesVO via RegistrationPageVL RegLinesRegPageVOItemDetailsVO via ItemDetailsVL ItemDetailsPageVOSearchPageRegistrationVO SearchPageRegistrationVOSearchPageRegistrationLinesVO via HomePageVL SearchPageRegistrationLinesVOAfter completing this, your “Data Model” should look like this:-http://kohlivikram.blogspot.com/
  34. 34. http://kohlivikram.blogspot.com/
  35. 35. Step 4) Click on finish.So you have finished creating the Business service layer using the ADF Businesscomponents. Your model structure should look like thishttp://kohlivikram.blogspot.com/
  36. 36. 2.8 ValidationsIn the Item Details page, we have a validation that quantity should be greater thenfive. This can be achieved by putting up this validation at entity level. We shouldprefer to put up the validations at entity level rather then at database level usingpl/sql or at client end using the JavaScript. Because in first case, application has tohit the database every time validation has to be executed which will degrade theperformance of the application by requiring the expensive JDBC calls. And later oneis not suitable, as later on if view technology need to be changed , or what if useraccess the data through other user interface.As Item Details page will be based on the ItemDetailsPageVO which in turn based onthe RegistrationLinesEO, we will put the validation that in the RegistrationLinesEO. Sohttp://kohlivikram.blogspot.com/
  37. 37. Step1 ) Select the RegistrationLinesEO under the model.entity and select the“Attributes”.Step 2) Select the Qty from the Attribute list and click on the “Add validation Rule”from the Validation Rules.Step 3) In the “Add Validation Rules for: Qty” , select the Rule Type as “Compare”.In the Operator select “Greater Than” and in the “Enter Literal Value” enter 5.Step 4) Now select the “failure Handling” tab in the same window and enter thefailure message as “Quantity should be greater the five”. And then click on “OK”.So this is how you can put up validations at the entity object level.Chapter 3Working on the Controller and UI.http://kohlivikram.blogspot.com/
  38. 38. We will now work on the controller and user interface for this application. We willstart with building the page template. Page template is one of the very importantfeatures in ADF 11g which let us define the entire page layout. When a page iscreated using a template, it will inherit the defined layout. When we make the layoutmodifications in the template, all the pages which are based on the template willautomatically reflect the changes.3.1 Steps to create the page template definitionStep 1) Select the “ViewFolder”, right click it and select “New”.Step 2) In the Categories tree, select the JSF node, in the Items pane select JSFPage Template, and click OK. Enter the File Name as “MyPageTemplate”.Step 3) Click the Facet Definitions tab and click the Add icon to add facets. Facets arepredefined areas on a page template where content can eventually be inserted whenbuilding pages using the template. Add two facets with name “MainPageRegion” and“ActionButtonBarRegion”.Step 4) Click on the Attributes tab and click on the Add icon to add attribute withname PageTitle with type java.lang.string and required as true.Step 5) Select the “Panel Stretch layout” from the Component Palette and drop it onthe af:pageTemplateDef in the structure window. “Panel Stretch layout” is ahttp://kohlivikram.blogspot.com/
  39. 39. geometry management component. This means that when user resizes the browser,Panel Stretch layout components will resize it self accordingly along with its childcomponents. Along with Panel Stretch layout, panelSplitter is the only othercomponent that supports geometry management.http://kohlivikram.blogspot.com/
  40. 40. http://kohlivikram.blogspot.com/
  41. 41. Now select the Panel Stretch Layout and set following properties in propertyinspector:-StartWidth = 0pxEndWidth = 0pxTopHeight = 95pxBottomHeight = 50pxStep 6) Now expand the bottom facet under the panel Stretch layout and insert apanelGroupLayout inside that. We are using the panel group layout as it allows itschild to be grouped vertically or horizontally. This is the facet under which we willadd our action command buttons aligned horizontally.Step 7) Now select the “Facet Ref” from the “common components” and drop it onthe newly created panelGroupLayout in above step. And in the “Insert Facet Ref”window select “ActionButtonBarRegion”.Step 8) Select the top facet under the panelStretchLayout and add apanelGroupLayout. Add an image component under that and then add an outputTextunder image. Set the Source property of the image =” /MyProcLogo.JPG”. And setthe value property of the outputText =” My Procurement Application”. And then addthe OutputText component from the common component palette and drop it belowthe above created outputText. And set the following properties of the OutputText inproperty inspector:- Value= # {attrs.PageTitle}. This is actually referring to the attribute we havecreated above when we were creating the page template definition. InlineStyle(under style) = font-weight:bold; font-size:small; vertical-align:text-bottom; color:Maroon;You will get the “MyProcLogo.JPG” from the application build by me.Step 9) Select the Center and add the panelStretchLayout inside it. And set thefollowing properties to it in property inspector:-StartWidth = 0pxEndWidth = 0pxTopHeight = 0pxBottomHeight = 0pxInside the center facet of the above added panel stretch layout, add apanelGroupLayout. Inside the panelGroupLayout drop a separator from the layoutcomponent palette.Under the output text drop the “Facet Ref” component from the common componentspalette. And in the “Insert Facet Ref” window select “MainPageRegion”.Your page template structure should look like as following in structure window.http://kohlivikram.blogspot.com/
  42. 42. We have finished creating the page template and now we will proceed to create ourapplication pages. Here is a plan; we will first create the Catalogue-Category page,as it is not much dependent on other UI pages. Then we will create the Item Listpage i.e. Item Search Page because of the same reason. And then we will create theRegistration page, then Item details page, and finally we will create the Home pagei.e. “Registration Search page”.3.2 Steps to create the Catalogue Category Pagehttp://kohlivikram.blogspot.com/
  43. 43. This page will show the catalogs - categories table as master table and inline detailtable and an items table under the master detail table showing item under selectedcategory.3.2.1 Creating the Master – Inline detail table to show Catalog-CategoriesStep 1) Select the “ViewController”, right click and select new.Step 2) In the Categories tree, select the JSF node, in the Items pane selects JSFPage and click ok.Step 3) Give the file name as “CatalogeCategoryPage” and select “MyPageTemplate”from the Use Page template drop down.Step 4) Select the af:pageTemplate from structure window and set pageTitle=”Catalogue Category Page”. Also select the af:document nod ein starcture window andset pageTitle=” Catalogue Category Page”.Step 5) now select the “Panel Collection” from the layout component palette anddrop it on the “MainPageRegion”. Now select the af:panelCollection from thestructure window and set the ID property to PanelCollectionRN and inline styleproperty under style from property inspector equal to “width:700px;”Step 6) Expand the data control palette, and select the CatalogPageVO and drop iton the af:panelCollection. From the context menu select “Tables->ADF Master Table,Inline Detail Table”.Step 7) In the “Edit Tree Binding window” select the model.view.CatalogVO and fromthe Available attributes, shift CatalogueName and Descrr to Display Attributes. Andshift back the CategoryId to the Available Attributes.Step 8) Add a new tree level rule by clicking on the green icon and select“CategoryVO” and shift the CategoryName and Descr to the display attributes andshift back the CategoryId to the Avaliable Attributes.Step 9) Select the Master table from the structure window and set the id properties= CatalogTbl. Expand the master table.Now set the width(under Apperance) of“CatalogeName” column to 250 and descrr column to 400.Step 9) Expand the detail facet under master table and set the id property =CategoryTbl and width=650px. Expand the CategoryTbl and set following propertiesof “CategoryName” columnwidth = 200 ,ID = CategoryNameColAnd select “Descrr” Column and set its width to 400.Step 10) Select the “af:outputText – {detailRow.CategoryName}” under the innerinline table column CategoryName. Right click and select convert from the contextmenu. From the convert Ouput Text, select Link from list of components and click ok.Click Ok in confirm convert window. Now set the Text property of the link to“#{detailRow.CategoryName}”. And partial submit (under Behavior) property inproperty inspector to true. We did this because on category name click, the itemtable(will be creating in next step) gets refreshed with the items under this category.And set the id of the link to CategoryNameLK.Step 11) Similarly convert the product code output text to link with Text property =#{row.ProductCode} and action = ‘CreateNewLine’.Step 11) Right click your catalogue category page, and select “go to page definition”.Replace<nodeDefinition DefName="model.view.CategoryVO"> <AttrNames> <Item Value="CategoryName"/> <Item Value="Descr"/> </AttrNames>http://kohlivikram.blogspot.com/
  44. 44. </nodeDefinition>With<nodeDefinition DefName="model.view.CategoryVO"> <AttrNames> <Item Value="CategoryName"/> <Item Value="Descr"/> <Item Value="CategoryId"/> </AttrNames></nodeDefinition>You will see that the all column header of the master table as well as detail table arenot properly named. To name them, you should open the relevant view object fromthe model.view and then set the Label Text under the control hit to appropriatename. For example double click the CatalogVO from the model.view. Select theAttributes and double click on the Catalogue Name. Under the control hints in “EditAttribute” window, set the Label Text as “Catalogue Name”. In a same way , set thelabel for other columns too. Your custom labels are getting stored in a messagebundle file called “ModelBundle.properties” under the model package.3.2.2 Create the Item table showing Items under Category using PPRPartial page rendering is the way by which your full screen will not get refreshed,rather then only the component which accepts the fired partial page request getsrefreshed.Step 1) Add a Panel Box under the MainPageRegion. Set the id of the newly createdaf:panelBox to ItemPanelRN, Text to Items and width to 650Step 2) now select the CatalogeCategoryItemVO from the data control palette anddrop it on the above created panel box. From the context menu select tables->ADFread only table.Step 3) In the Edit Tables Columns, delete all column except ProductCode, Descr1,UOM, UnitPrice. And check the Sorting check box to enable users to sort the items.Step 4) Now select the item table (af:table node) and set the partialTriggers. SelectEdit from partialTriggers. It will open the Edit Property window. Now select thecommandLink- CategoryNameLK and shift it to selected pane and click ok. If somehow “Add to Select” is not enabled then make sure that you have given id for eachcomponent in the command link hierarchy.http://kohlivikram.blogspot.com/
  45. 45. We are done with the process by which the Item table will gets refreshed when theCategory Name link is clicked by user. But still the page will show all the Items ratherthen showing the items under the selected Category. To achieve this, we will put up amethod in Application module to set the required filter condition.3.2.3 Filtering items under selected categoryStep 1) Generate the application module java class. Double click your applicationmodule under the model node. Select Java section in code editor and then click onthe Edit java options.Step 2) In the Select Java Option, select “Generated Application Module Class” checkbox and click ok.http://kohlivikram.blogspot.com/
  46. 46. This will generated your AMImpl class where you can write service methods.Step 3) Open your AMImpl class by selecting class under “MyLearningAM” node inApplication Navigator. And add following code in that:- public void getItemInCategory(String CategoryId){ ViewObjectImpl voItem=getCatalogueCategoryItemVO(); voItem.setWhereClause("CATEGORY_ID1 = " + CategoryId); voItem.executeQuery(); }Step 4) Again select your “MyLearningAM” node, and then java tab in code editor andclick on the “Edit Application Module Client Interface” . In the “Edit Client Interface”window, shift the getItemInCategory() method from Available list to Selected list andclick ok.For the method to be accessible in view layer and to be added to data controlpalette, we have to put the method in AM client interface.Step 5) now you will see that above added method will appear in the data controlpalette. Delete the existing <af:commandLink - "#{detailRow.CategoryName}"> andSelect the getItemInCategory and drop it under the CategoryName column andselect MethodsADF Link.http://kohlivikram.blogspot.com/
  47. 47. Step 6) In the Edit Action Binding window set parameter value as#{detailRow.CategoryId}.Now set the following properties on this af:commandLink:-Id= CategoryNameLKText = #{detailRow.CategoryName}PartialSubmit = true.Your Catalogue Category page is ready to run.3.3 Steps to create the Item List PageThis page will help the user to search a particular item. Following are the steps tocreate this page:-Step 1) Create a new jsf page with name “ItemListPage” under the ViewControllerproject. It should be created based on the above created template.Step 2) Select the af:pageTemplate and set the pageTemplate to “Item List Page”.Step 3) Select af:document and set the title property to “Item List Page”.Step 4) Select the ItemListPageVONamed CriteriaItemListPageVOCriteria anddrop it on the MainPageRegion and select Query”ADF Query Panel with Table”.http://kohlivikram.blogspot.com/
  48. 48. Step 5) In the Edit Table Column delete all columns except “CatalogueName”,”Descrr”, ”CatageoryName”, ”Descr”, ”Product Code”, “Descr1” and “Unit Price”.Step 6) Select the af:table –resId1 and then set the width to 900.Set the columnwidth of each column as per requirement.Step 7) As User will move from this page to the Item details page, we will convertthe af:outputText - #{row.ProductCode} to af:link. So right click it and select“Convert” option. And select Link form the Convert Output Text window and click onok. And in confirm convert window, click ok.Step 8)Set the Text property of the newly converted link to #{row.ProductCode}.Andthe Action property to the CreateNewLine.Step 9) Inside the above command link add a action listener withfrom=#{row.ProductCode} and to=#{requestScope.ProductCode}. To add the actionhttp://kohlivikram.blogspot.com/
  49. 49. listener, right click the command link and select the “insert inside af:commandlink-->ADF Core--> Set Action Listener”.Step 9) Now select the af:panelHeader and set the text property to “Search Item”.Your Item List page is ready. Run it check the results.3.4 Steps to create the Registration PageSo finally the big fish has arrived. Registration page is the one which will allow theuser to create the new registration and to edit the existing one. Following are thesteps to achieve this:-Registration Details RegionStep 1) Create a new page with name “RegistrationPage” based on the template“MyPageTemplate”.Step 2) Set the page title as “Registration Page” and page window title also as“Registration Page”.Step 3) Select the Panel Splitter from the layout components and drop it on theMainPageRegion in the structure window.Step 4) Select the newly created af:panelSplitter and set the following properties inthe property inspector:-SplitterPosition = 454, id=”FirstRN”.Style = width:943px; height:200px;Step 5) Select the PanelGroupLayout from the layout components and drop it on thefirst facet of above created panelSplitter. Select the newly created panelGroup andset the layout property as “scroll”.Step 6) Inside the panel group layout add a output text with value as “RegistrationDetails”. And below the output text, add the separator from the layout components.Step 7) Now select the PanelFormLayout from the layout component and drop itinside the created panel group layout below the separator.Step 6) Now select the RegistrationPageVORegNum from the data control and dropit on the above created panel form as TextADF Output Text w/ Label.Step 7) Select RegistrationPageVOProcType from the data control and drop it belowthe above created output text as Single SelectionADF Select One Choice. In theEdit List Bindings window, select “Fixed List” option. Set the Base data sourceattribute as “ProcType” and enter following items in the set of values one by one,each item seprated by “enter” key:- Standard Procurement  Emergency  Reimbursable Procurement and click ok.Step 8) Select RegistrationPageVORegStatus from the data control and drop itbelow the above created ProcType choice list. Again created the fixed list choice boxas above, with values as Open and Closed.Step 9) Select RegistrationPageVOUrgency from the data control and drop it belowthe above created RegStatus choice list with, Created the fixed values choice list withvalues Normal and Urgent.Step 10) Drop the TotalUsdAmt and TotalPfiAmt from RegistrationPageVO in datacontrol and drop it below the above created Urgency choice list one by one as TextADF Output Text w/ Label.Creation Details Regionhttp://kohlivikram.blogspot.com/
  50. 50. Step 1) Select the PanelGroupLayout from the layout components and drop it on theSecond facet of above created panelSplitter “FirstRN”. Select the newly createdpanelGroup and set the layout property as “scroll”.Step 2) Inside the above created panel group layout add an output text with value as“Creation Details”. And below the output text, add the separator from the layoutcomponents.Step 3) Select the PanelFormLayout from the layout component and drop it insidethe created panel group layout below the separator.Step 4) Select the RegistrationPageVOCreatedByName and RegistrationPageVOCreationDate one by one, from the data control palette and drop it on the abovecreated panel form as TextADF Output Text w/ Label.Step 5) Select the RegistrationPageVORequestedBy from the data control and dropit as Single SelectionADF Select One Choice.Step 6) Select the RegistrationPageVODepartmentName from the data controlpalette and drop it on the above created panel form as TextADF Output Text w/Label.Notes to Buyer RegionStep 1) Add a spacer below the “FirstRN” panel splitter. Below that add another panelsplitter with ID= SecondRN and splitterPosition=452.Step 2) Inside the first facet of the “SecondRN”, add a panel group layout.Step 3) Inside the panel group layout add a output text with value as “Notes toBuyer”. And below the output text, add the separator from the layout components.Step 4) Select the RegistrationPageVONotesBuyer and drop it on the above createdpanel group as TextADF Input Text. And set the Rows property of newly createdtext box to 5.Party Notes RegionCreate this region in a similar fashion as Notes to Buyer region is created in thesecond facet of the SecondRN based on RegistrationPageVOPartyNotes from datacontrol.Registration Lines RegionStep 1) Add a spacer below the “SecondRN” and then add an output text with value= “Registration Lines” in the structure window of registration page.Step 2) Add a separator below the above created output text.Step 3) Add a command button below the above separator with Text= “Add Item”and action =” CatalogPage”. This button will help the user to navigate to the “CatalogCategory Page”.Step 4) Add another command button below the above command button with textproperty =”Search Item” and action=” ItemLitsPage”. This button will lead the userto Item list page once the action property of the button is set.Step 5) Now select the RegistrationPageVORegistrationLinesVO from thedatacontrol palette and drop it on the af:group as TablesADF Read Only table.Step 6) From the Edit Table Columns window, delete “LineId”, “RegistrationId” andclick ok.http://kohlivikram.blogspot.com/
  51. 51. Adding Registration Managed BeanWhen user navigates from the Home page to the Registration page by clicking on the“New Registration” button, the page appear in the new registration creation mode. Inthat case “Add Item” buttons and “Search Item” buttons in the Registration Linesregion should be disabled. As the registration it self is not yet created, user shouldnot be able to add the lines in registration. So we have to disable these buttons fornew registration and when user clicks on the “Save” button buttons should beenabled. We will achieve this with the help of managed bean.A managed bean is a regular java bean whose bean properties and methods are bindto the JSF components. We will use these properties to enable and disable thecommand button in our registration page.Step 1) Right click the view controller project and select new. From items sectionselect “Java Class”. In the Create Java Class window specify Name asRegistrationBean and package as “view.beans” and click ok.Step 2) Add following two variables in the RegistrationBean class and generateaccessors for both the variable(you can generate the accessors by right clicking on itand selecting ‘Generate Accessors’ from the context menu. private boolean disableAddItemBtn; private boolean disableSearchCataBtn;Step 3) Now we have to declare the above managed bean in the adfc-config.xml file.Open the adfc-config.xml file and in the code editor window, select Overview fromthe bottom of the window. Click on the “Add” icon and specify details as shownbelow:-Step 4) Now we should also specify the initial value of the above created variable,which should be ‘false’ as “Add Item” and “Search Item” should be enable all thetime except for the new registration request. For this select the Managed Propertiesand click on “Add” icon and add following properties:-Step 5) Select the “Add Item” command button and set the Disabled property =#{RegistrationBean.disableSearchCataBtn}And then select the “Search Item” command button and set the Disabled property =#{RegistrationBean.disableSearchCataBtn}http://kohlivikram.blogspot.com/
  52. 52. Action Button Bar RegionStep 1) Select the OperationsCommit from the data control palette and drop it onthe ActionButtonBarRegion in the structure window and select operationsADFButton form the command window. Change the text property of the command buttonfrom Commit to Save and disabled property to false.Step 2) Insert inside the Save command button two action listener with followingvalues:-From= #{false} and To= #{RegistrationBean.disableAddItemBtn} From= #{false} and To= #{RegistrationBean.disableSearchCataBtn}Step 3) Add another command button inside the ActionButtonBarRegion with Textproperty = “Home” , Action property =” HomePage” and Immediate property set totrue.Your registration page layout in structure window should look like:-http://kohlivikram.blogspot.com/
  53. 53. This finishes the layout of the Registration page, our big fish. We will now work withcontroller to define the flow of the system.3.5 Creating ‘Edit Registration’ bounded task flowA task flow is one of the best new features introduced in the ADF 11g. ADF task flowdefines the control flow in the application. The nodes in the application are calledactivities representing a logical operation such as displaying a UI page, executinghttp://kohlivikram.blogspot.com/
  54. 54. method in managed bean or application module or calling another task flow. ADFcontroller which is build up using task flows is implementation on top of JSF. Thereare two types of ADF task flows:-Bounded task flow: - It is a self contained unit of work that acts as a function. It hassingle entry point, a set of input parameters and one or more ways to return control.Unbounded task flow: - It is a task flow with no boundaries and allows users to startat any page. Bounded task flows are called with in an unbounded task flow.In this sample application, we will create one bounded task flow called ‘Editregistration’. Question arises why? Because Registration page functionality can beconsidered as a single unit of work. Registration can either be displaying an existingregistration, or will be used to create new registration. And registration page will becalled up from different view pages. So it is better to create the registration page asa single unit of work.For more learning on task flow hithttp://www.oracle.com/technology/oramag/oracle/08-sep/o58frame.htmlSteps to create the ‘Edit Registration’ bounded task flowStep 1) Select the ViewController right click it and select new. Select “ADF Task Flow”from the Web TierJSF.Step 2) In the create task flow window, set the file name as ‘Edit-Registration’ andselect the “Create as Bounded Task Flow” check box. Deselect the “page fragment”check box and click ok.Step 3) Under the page flow directory your newly created task flow is added. Open itin code editor.Step 4) Click on the blank area in the code editor. Select parameters from theproperty inspector. And create two input parameters and one output parameter asfollowsStep 5) Add a router activity in the above created task flow with id=”RouteByMode”.A router activity acts as an IF condition which transfers the control based on theexpression language.http://kohlivikram.blogspot.com/
  55. 55. Step 6) Select the above created router activity. From the property inspector underthe common node, specify two cases as below:-Step 7) Select the Method call activity from the component palette and drop it on thecode editor. Set the ID of the new method activity as “CreateNewRegistration”.Step 8) Now select the RegistrationPageVOOperationsCreateInsert from the datacontrol palette and drop it on the CreateNewRegistration method activity.Step 9) Select a control flow case from component palette and drag it fromRouteByMode to CreateNewRegistration. And set the from-outcome to “Create”Step 10) Create another method activity with ID as “FindRegitration” . ConnectRouteByMode to FindRegistration with from-outcome as “Edit”.Step 11) Select the RegistrationPageVOOperations setCurrentRowWithKeyValuefrom the data control palette and drop it on the “FindRegistration” method activity.Now right click the “FindRegistration” activity and select “Edit Bindings”. In the EditAction bindings, set the parameter value=#{pageFlowScope.regToEdit} and click ok.Step 12) Select the RegistrationPage.jspx from the application navigator window, anddrop it on the cod editor.Step 13) set the control flow from the “CreateNewRegistration” to the“RegistrationPage”.Step 14) Again set the control flow from the “FindRegistration” to the“RegistrationPage”.Step 15) Drop a “Task Flow Return” activity on the page flow with name property =“CatalogPage” and id=” GoToCatalogPage”Step 16) Drop second task flow activity on the page flow with name property =“ItemListPage” and id=”GoToItemListPage”.Step 17) Drop yet another task flow activity on the bounded task flow with nameproperty =”HomePage” and id=”GoToHomePage”Step 17) set the control flow from “RegistrationPage” to “GoToCatalogPage” withfrom-outcome property =”CatalogPage”.Step 18) set the control flow from “RegistrationPage” to “GoToItemListPage” withfrom-outcome property =”ItemLitsPage”.Step 19) set the control flow from “RegistrationPage” to “GoToHomePage” with from-outcome property =” HomePage”. This from-outcome property is equivalent to theaction property we have set for the Home command button in the registration page.Your bounded task flow should look like:-http://kohlivikram.blogspot.com/
  56. 56. 3.6 Creating Home pageStep 1) Create your home page with name “HomePage” based on the created ADFtemplate we created.Step 2) Select SearchPageRegistrationVONamed CriteriaSearchPageRegistrationVOCriteria and drop it on the MainPageRegion in structurewindow. And select QueryADF Query panel.http://kohlivikram.blogspot.com/
  57. 57. Step 3) Expand the af:PanelGroupLayout and select af:panelHeader. And set the textproperty =” Search Registration”.Step 4) Now select the SearchPageRegistrationVO and drop it on the MainPageRegionand select the TablesADF Master Table,Inline Detail Table option.http://kohlivikram.blogspot.com/
  58. 58. Step 5) From the “Edit Tree Binding” for the “model.view.SearchPageRegistrationVO”,shift all the attributes from available attributes to display attributes except“RegistrationID”.Step 6) Click on the “Add Rule” icon and select “SearchPageRegistrationLinesVO”.Select “model.view.SearchPageRegistrationLinesVO” rule and set display attributes as“ProductCode”,”Qty” and “Uom”. And click ok.Step 7) Select the newly created af:table and set the following properties:-ID = resultTblWidth=900.And set the width of the each column respectively as required.Step 8) Add a Panel Box layout from the component palette window in the structurewindow under MainPageRegion”. And set the text property of the panel box to“Registration List”.Steps 9) Add the above created table in step 5 inside the above created panel box.Step 10) Select the af:query region and set the ResultComponentID property underthe Behavior node to “::resultTbl”. It means that the query results will be shown inthe above created table.http://kohlivikram.blogspot.com/
  59. 59. Step 11) Convert the output text for registration number to link with text property=#{row.RegNum}Step 12) Inside the Action button bar add a command button with following propertyvalues:-Text = New RegistrationAction =NewOrEditStep 13) Right click your command button and select “Set Action Listener” as shownbelow:-In the “Insert Set Action Listener” set From = #{New} and To =#{requestScope.mode}. This action will put the value ‘New’ in the mode attribute.This mode method is acting as a input parameter for the ‘Edit-Registration’ boundedtask flow we created in step 4 of 3.5 exercise.Step 14) Insert another action listener with From= #{true} and To=#{RegistrationBean.disableAddItemBtn}Insert yet another action listener with From= #{true} and To=#{RegistrationBean.disableSearchCataBtn}Your final structure window for the home page should look like:-http://kohlivikram.blogspot.com/
  60. 60. 3.7 Creating Item Details pageSo we are now at final page of our application. We will create this page layout andafter that in our last step in creation of this application, we will define the applicationflow in ADF controller. Item details page is used to create a new registration line inthe existing regStep 1) Create a new jspx page name “ItemDetailsPage” based on created pagetemplate.Step 2) In the MainPageRegion, add a panel header region.And then set the textproperty = #{bindings.RegNum.inputValue}.Step 3) Inside the header region, add a separator under the panel header.Step 4) Add a panel splitter component under the separator component. Set thefollowing property of newly created panel splitterSplitterPosition = 338Inline style = width:620px;Step 5) Select “ProductCode” in RegistrationPageVOItemDetailsPageVO from datacontrol palette and drop it on the first facet as “ADF Output Text w/ Label”Step 6) Select “Qty” in RegistrationPageVOItemDetailsPageVO from data controlpalette and drop it under above output text as ““ADF Input Text w/ Label”.Step 7) Select “UnitPrice” in RegistrationPageVOItemDetailsPageVO from datacontrol palette and drop it on the first facet as “ADF Output Text w/ Label”Step 8) Under the second facet of the panel splitter, drop the “Uom”, “Currency” and“Descr” in RegistrationPageVOItemDetailsPageVO from data control palette anddrop it under above output text as ““ADF Input Text w/ Label”.Step 9) Select OperationsCommit from the data control palette and drop it insidethe ActionButtonBarRegion as adf button with Text = ‘Save’ and action =’SaveRegLine’. And add another command button inside the ActionButtonBarRegionwith Text=’Cancel’ and Action=’ SaveRegLine’. So the Save button will commit thehttp://kohlivikram.blogspot.com/
  61. 61. data as well as navigate to the Registration page, but cancel will just navigate toregistration page. Now in both the command button add action listener with From=#{Edit} and To= #{requestScope.mode}And your layout for the page Item details is ready.3.8 Define Application flow in ADF ControllerStep 1) Open the ViewControllerWeb ContentPage Flow and open adfc-config inthe code editor.Step 2) Select the HomePage.jspx from the application navigator and drop it in thecode editor.Step 3) Now select the bounded task flow we have created “Edit Registration” fromPage Flows folder and drop it on the code editor. It will show an error on it as theparameters expected by the bounded page flow has not been set yet.Step 4) Select the “Edit-Registration” and in the property inspector under theparameter node set the value=#{requestScope.mode} for ‘mode’ parameter andvalue=#{requestScope.regToEdit} for the regToEdit parameter. And define the outparameter ‘regToEdit’ with value= #{pageFlowScope.regToEdit}.Step 5) Select the “Control Flow Case” from control flow in component palette, drag& drop it from “HomePage” activity to “Edit-Registration” activity. And set the from-outcome property to “NewOrEdit”. This NewOrEdit is the action property we set forthe ‘NewRegistration’ command button.Step 6) Select the CatalogueCategoryPage.jspx from the application navigatorwindow and drop it on the code editor.Step 7) Select the “Control Flow Case” from control flow and drag & drop it from“Edit-Registration” activity to “CatalogeCategoryPage” activity with from-outcome to“CatalogPage”.Run your application and see if you can create a new registration. Verify that theCreation date; Registration Number fields are getting shown with default values.Check if the required indicator is appearing in the UI. We have done this setting atthe RegsitrationEO entity level.http://kohlivikram.blogspot.com/
  62. 62. Let’s proceed now with updating page flow so that user can add lines in theregistration.Step 8) Select a method activity from the component palette and drop it on the adfc-config.xml in code editor with id=’ CreateNewLine’. Now select theRegistrationPageVOItemDetailsPageVOOperationsCreateInsert and drop it onthe newly created method activity ‘CreateNewLine’. CreateInsert operation insert anew blank row in the entity object.Step 9) Select the ‘Control Flow case’ from the component palette, drag & drop itfrom ‘CatalogueCategoryPage’ to ‘CreateNewLine’ activity with from-outcomeproperty= ‘CreateNewLine’.Step 11) Now as the item details page gets rendered, it gets rendered with thedetails of the item selected in the catalogue category page. To display these detailson the item details page we will set the required details in the blank row created inItemDetailsPageVO in step 8. To achieve this we will write a custom method inapplication module Impl class which will set the required item details in theItemDetailsPageVO. Add the following code in your application module Impl class:- public void initilizeNewRegLines(String productCode,String regId) { ViewObjectImpl itemVO=getItemListVO(); String clause ="PRODUCT_CODE = " + productCode + ""; itemVO.setWhereClause(clause); itemVO.executeQuery(); itemVO.setCurrentRowAtRangeIndex(0); ItemVORowImpl itemRow=(ItemVORowImpl)itemVO.getCurrentRow(); ViewObjectImpl newItemLineVO=this.getItemDetailsPageVO(); ItemDetailsVORowImplnewGoodsLineRow=(ItemDetailsVORowImpl)newItemLineVO.getCurrentRow(); newGoodsLineRow.setProductCode(productCode); Number unitPrice=itemRow.getUnitPrice(); String uom= itemRow.getUom(); String currency= itemRow.getCurrency(); String manufacturer = itemRow.getManufacturer(); if(unitPrice!=null) newGoodsLineRow.setUnitPrice(unitPrice); if(uom!=null) newGoodsLineRow.setUom(uom); if(currency!=null) newGoodsLineRow.setCurrency(currency); if(manufacturer!=null) newGoodsLineRow.setManufacturer(manufacturer); if(regId!=null) { try { newGoodsLineRow.setRegistrationId(new Number(regId)); } catch (SQLException e) { } } }http://kohlivikram.blogspot.com/
  63. 63. Add the above method in the application module client Interface.Step 12) Select the initilizeNewRegLines from the data control palette and drop it onthe adfc-config.xml in code editor. In the “Edit Action Binding” under the parametersection specify values asStep 13) Select the flow control from the component palette, drag & drop it from‘CreateNewLine’ to ‘initilizeNewRegLines’ activity with from-outcome property=‘’CreateInsert’.Step 14) Select the ItemDetailsPage from the application navigator, drag and drop itin the adfc-config.xml file in code editor. And define the control flow activity from‘initilizeNewRegLines’ to ‘ItemDetailsPage’ activity with from-outcome=initilizeNewRegLines.Step 15) Define a control flow from ItemDetailsPage view activity to Edit-Registrationtask flow call activity with from-outcome= SaveRegLine. And then define a controlflow from the “Edit-Registration” to “HomePage” with from-outcome= HomePage.Run your application, with home page, you should be able to create and save theregistration. And then add the new line by clicking the “Add Item” button on theregistration page.When you run your application and add the registration line in the registration, youradded lines will not be shown in the registration lines table region in the registrationpage. To achieve this we have to execute the iterator with which the registration linestable is associated.Step 16) Select the RegistrationPageVO-->RegLinesRegPageVO-->Operations-->Execute from the data control palette and drop it on the adf-config.xml in codeeditor. Set the id of the activity to ExecuteRegLines.Step 17) Delete the control flow case between the ItemDetailsPage and Edit-Registration.Step 18) Select the flow control from the component palette, drag & drop it from‘ItemDetailsPage’ to ‘ExecuteRegLines’ activity with from-outcome property=‘SaveRegLine’.Step 19) Select the flow control from the component palette, drag & drop it from‘ExecuteRegLines’ to ‘Edit-Registration’ activity with from-outcome property=‘Execute’. Now run the application, registration lines region in the registration pagewill show the added line in the registration.Another navigation case is to go to item list page from registration page and searchthe item. And from Item list page to item details page where we will add the quantityof the item and navigate back to the Registration page. To achieve this , follow thefollowing steps:-http://kohlivikram.blogspot.com/
  64. 64. Step 20) Select the item list page from the application navigator and drop it on theadf-config.xml in the code editor.Step 21) Define control flow from Edit-Registration to ItemLitsPage with from-outcome=ItemListPage. And from the ItemListPage to the CreateNewLine methodactivity with from-outcome=CreateNewLine.Now you will be able add a line in registration from the item list page.Also we also have to open the exiting registration from the Home page. To achievethis open your home page. Now under the registration number command link addthe following two action listener under that as :-1) from="#{Edit}" to="#{requestScope.mode}"/> 2) from="#{row.RegistrationId}" to="#{requestScope.regToEdit}"And finally, as we have the “Total USD Amount” and “Total PFI Amount” in theregistration page which will show the total USD amount of the registration lines andtotal PFI(package, fright and insurance) amount of the registration lines added in theregistration. To achieve this we will add the method in the application module customJava class which will iterator through the registration lines related to currentregistration with the help of view link. Add following code in the application moduleImpl class:- public void updateRegLinesAmt() { ViewObjectImpl vo = getRegistrationPageVO(); RegistrationVORowImpl currRow=(RegistrationVORowImpl)vo.getCurrentRow(); RowSet items = (RowSet)currRow.getRegistrationLinesVO(); double totalUsdAmt=0.0,totalPfiAmt=0.0; String usdAmt=null,pfiAmt=null; if(items.getEstimatedRowCount()!=0) { while (items.hasNext()) { Row curItem = items.next(); usdAmt=curItem.getAttribute("UsdAmount").toString(); pfiAmt=curItem.getAttribute("UsdPfiAmount").toString(); System.out.println("USD Amount= " + usdAmt + " , pfi Amt=" + pfiAmt); if(usdAmt!=null) totalUsdAmt = totalUsdAmt + Double.parseDouble(usdAmt); if(pfiAmt!=null) totalPfiAmt = totalPfiAmt + Double.parseDouble(pfiAmt); } System.out.println("totalPfiAmt="+totalPfiAmt + " totalUsdAmt= " +totalUsdAmt); try { currRow.setTotalPfiAmt(new Number(totalPfiAmt)); currRow.setTotalUsdAmt(new Number(totalUsdAmt)); } catch (SQLException e) { }http://kohlivikram.blogspot.com/
  65. 65. //commit(); } }Expose the above method in the application module client. Now open your EditRegistration page flow, select the updateRegLinesAmt from the data control palette anddrop it in the code editor window in the Edit-Registration page flow in between theFindRegistration and RegistrationPage activity as shown below:-Procurement application is ready. Test it and let me know how your feedback on thisand and error in the documentation. I will keep working on the application and willimprove it further and update the document.Please let me know any errors or suggestions to improve the document.Happy Learning.http://kohlivikram.blogspot.com/

×