Saturday, December 29, 2012

ADF Data Model – Detail with Multiple Masters



      1.       In this Example, a Many to Many Relationship in the database is captured in AM Data Model as Detail with Multiple masters.
      2.       Data Model shows a MMD_PRODUCT, MMD_STORE have a many to many relationship using MMD_INVENTORY.
        3.       Create ADF BC components for the above tables.



        4.       In AM Data Model, add Product view instance and Inventory view instance as a child.





      5.       Next step is the important step to capture the Detail with Multiple masters. Add Store view instance and Inventory view instance as a child. When adding a view instance with the same name as an existing instance, you will be given an option to use the existing instance. Select Yes.






      6.       As you can observe now Inventory View Instance is a child of both Product and Inventory.
      7.       You can easily create a Master Master Detail relationship in ADF page as below. When you change the selection in either Product (Master) or Store (Master) the Inventory (Detail) gets updated.


You can download the complete example here.


ADF Global Style Selectors, AFStretchWidth and others

ADF Faces provides a easy way to style components using Skinning.

Apart from skinning components, Global Style Selectors help with layout of the components. AFStretchWidth is one of the most frequently used global style class used to stretch a component horizontally.

For a complete list of you can browse through Oracle Documentation here.

Sunday, December 16, 2012

ADF Query Panel with CheckBox (Boolean search attribute)


In database the Boolean values in a column are usally stored as Y and N. This example shows how to search such columns using CheckBox.

      1.       Add a new attribute in view object. Select Mapped to Column or SQL, unselect Selected in Query, provide the alias and SQL expression DECODE(ACTIVE,’Y’,1,’N’,null).




         2.       In the attribute control hints select control type as Check Box



       3.       In query tab create view criteria to use as search panel.


       4.       From data controls, drag and drop the view criteria as ADF Query panel with table.


        5.       Run the page and use the checkbox to search for active and inactive users.


      6.       You can also provide a default value for the checkbox in viewcriteria.
    
      7.       You can download the complete example here.

Master Form Detail SelectManyChoice


In my earlier post I showed an example to use SelectManyShuttle as a detail in Master-Detail pattern, you can also use other multi select components as details.

Below shows SelectManyChoice being used as the detail.




All you need to do is in step 6 (from post) just update the page xml as below instead.


Saturday, December 15, 2012

Master Form Detail Multi Select Shuttle Pattern




Below Example demonstrates having Master Form with detail as Multi Select Component.

      1.       Data Model. Each Employee can have one or more skills. All possible skills are stored in SKILLS table. Each employee skills are stored in EMPLOYEE_SKILL.

This example user Oracle default HR Schema, additional tables can be created from SelectManyShuttle\DB\database\XE\CreateSchema.sql. File is available in the application zip.

      2.       Setup the Application Module Data Model as below.




      3.       From the Data Control Panel drag and drop the Employee -> EmployeeSkill as ADF Master Form, Detail Table as below



        4.       Create a request scope Bean and add setter and getter method as below



      5.       Now to create a List of all skills add a Table binding. Go to page bindings tab, click the add under bindings. Select tree. Add a new root data source. Select Skills view object. Select the Add Icon and Add Rule. Select SkillId, SkillName as Display attributes.




       6.       Delete the skills table, and a SelectMultiShuttle component. Bind the value to bean property. To dynamically create a selectItem list, we’ll use a forEach loop.


      7.       For the current employee the available skills should get defaulted to employee skills from EMPLOYEE_SKILL table, accordingly when the items are updated the rows need to get added/removed accordingly. We’ll add the logic in setters and getters to achieve this.


        8.       Download the complete example here.

ADF View Object - View Criteria Row with SQL Literal

View Criteria provides an ability to decoratively add a where clause fragment to view object. 

Jdeveloper GUI by default provides option to declare a view criteria items value either as a 
  1. Literal 
  2. Bind Variable. 
There is also support for adding a literal that would be treated as a 
  1. SQL fragment
Below steps show how to configure
      1.       Create View Criteria, Add a view criteria item, Select operator as HireDate, Operator as Between and Operand as Literal

       2.       Go to the Source Tab of the View Object and add an IsSqlFragment attribute with value true in view criteria item value as below.



          3.       From the View Criteria Editor provide values sysdate-3650 and sysdate


       4.       Click on Test button to validate the Query


       5.       To Test the Apply the View Criteria in Application Module Data Model.


        6.       Run The Query from SQL WorkSheet and AM tester to compare the results.


       7.       The Sample application attached here. Let me know if you have any questions.
       8.       You can also use the same logic for other operators; ViewCriteriaRow also supports the IsSqlFragment attribute. Here is an example.
Related Posts Plugin for WordPress, Blogger...