Pages

Friday, August 31, 2012

Great WebCenter Tutorial

I found an excellent tutorial on WebCenter by Yannick Ongena. It is very helpful for novice webcenter developers.
Blog: http://www.yonaweb.be/webcenter_tutorial/introduction 
Very easy to get started with WebCenter after reading this tutorial. The concepts are very well explained with a lot of screen shots.

Another blog from Yannick Ongena for installing webcenter:
http://yonaweb.be/installing_webcenter_11g_ps3_scratch 

Thursday, July 5, 2012

How to pass Oracle Table Type Object from Java Code to Oracle Stored Procedure

I had a requirement to pass Oracle Table Type Objects to a Store procedure. In this blog, I will explain how we can pass the Table type object from Java code.

The table type objects I used are: 
JTF_NUMBER_TABLE               //Table type of Number Type       JTF_VARCHAR2_TABLE_100  //Table type of Varchar2(100) Type
These two objects are input parameters to the stored procedure.

If you have Number, String Array as shown below:
Number[] srContactPointId = new Number[4];
String[] contactType = new String[4];   

These can be passed as Table type Object using the following code.

//Getting hold of the transaction
DBTransaction txn = (DBTransaction)wrsAmImpl.getDBTransaction();
OracleCallableStatement cstmt = (OracleCallableStatement)txn.createCallableStatement(cs, 1);

//Getting the Connection Object
Connection conn = cstmt.getConnection();

//Creating oracle.sql.ArrayDescriptor Object for corresponding Table Type Object.
ArrayDescriptor numberDescriptor =  new ArrayDescriptor("APPS.JTF_NUMBER_TABLE", conn);
ArrayDescriptor stringDescriptor =  new ArrayDescriptor("APPS.APPS.JTF_VARCHAR2_TABLE_100", conn);

//Creating oracle.sql.ARRAY object to be passed to the Oracle Stored Procedure
ARRAY contactPointId = new ARRAY(numberDescriptor , conn, contactPartyId);
ARRAY contType = new ARRAY(stringDescriptor , conn, contactType);

Tuesday, July 3, 2012

Defining a tooltip for Table filter column/field.

In one of my project I had a requirement to show tool tip/short description for a table column filter. In this post, I will explain how to define tool tip for table filter.

- Select the column in the table for which you want to define tool tip. 

- Expand Column facets node for that column and select filter facet. 

- Inside the filter facet insert an Input Text component and set it's value property to #{vs.filterCriteria.Summary}, where vs is the VarStatus property in the table and Summary is the attribute name. 
Setting this value, will query the column attribute, without customizing the filter component.


 - The custom tool tip for the table column filter can now be set on the shortDesc property of Input Text. After this modification, the column code looks like:


UI

Monday, July 2, 2012

Using groovy expression for throwing dynamic error message

In this post, I will explain a simple use case of groovy expression for throwing error message.

If there is a Business rule defined on an Entity Object attribute such that, a Date value cannot be less than the current Date and if this Business Rule is violated an error message should be thrown like : The value entered, <enteredDate> is less than the Current Date <currDate>.

For this add an attribute validator on the date attribute.

Select the rule type as Script Expression and define the rule as shown below:


In the failure handling tab, define the message string as shown:


Map the enteredDate to newValue and currDate to adf.currentDate in the token message expressions.

When this rule is violated the error message is shown as:

Sunday, June 24, 2012

Select/Deselect All check box in a table

Select All/Deselect All check box in a table is a common requirement. This can be implemented in multiple ways. In this blog, I will explain the steps, I used for one of my project.

Follow these steps:

-  Add a transient attribute(say SelectDept) of type Boolean in the view object. Don't forget to set the updatable property to Always. 

-  Drag and drop the view object from the data control as an ADF Table

- Convert the SelectDept column to SelectBooleanCheckBox. Add command links to select/deselect check box in the header facet of this column.

- Call managed bean methods on click of the command link. After all these modifications the column code should look like:


- The bean methods onSelectAll, onDeselectAll in turn calls the method selectAllDept, deSelectAllDept respectively in AMImpl.java. It basically iterate through the RowSetIterator of DepartmentsView and set the value of SelectDept attribute, depending on the method being called.


UI Page:

Instead of command links (Select All/Deselect All), you can have a select boolean check box as well. On selecting it, all the check box are checked and un-selecting it will un-check all the check box in the table.

This code is also available in sample work space. Uncomment the select boolean check box in the column header facet and put the partial triggers of this boolean check box on the table.


Sample Workspace:
Download the sample workspace from HERE.

Saturday, June 23, 2012

SelectManyCheckBox component in a table

This post is very similar to my earlier post on Implementation of SelectManyCheckBox component. The use case/functionality remains same. But it defers only in the usage of SelectManyCheckBox component. In earlier post, I used it in a form layout. In this blog, I will explain how to use SelectManyCheckBox/SelectManyChoice component inside a table column for persisting/displaying the selected values for an EMP record  as shown:



Steps are:
1. Create a Fusion Web Application.
2. Create all the required Business Components (EO, VO,VLink AM) for the above data model.
3. Create a view link between EmpVO and EmpRolesVO, which will be used to display the SelectManyCheckBox as selected for an EMP record/row.

The above 3 steps are similar to the steps in earlier post.

4. Create two transient attributes SelectedRoles, StoredRoles in EmpVO. StoredRoles is used to fetch the selected roles from db for an EMP record. Where as SelectedRoles is populated when roles are selected for an EMP record from the UI.  

5. Override the getter method of StoredRoles attribute in EmpVORowImpl as shown below:


6. Drag and drop EmpVO as ADF table on the page.

7. Create another column in the table and then drag a SelectManyCheckBox UI component in it and bind the value property of it to a managed bean, which evaluates the Roles to be displayed as selected for an EMP row as shown:


Here the expression #{row} will give handle of each row being stamped in the table. Using this row, we can get StoredRoles attribute which is calculated in the getter method (EmpVORowImpl) for each EMP row using the ViewLinkAccessor as explained in Step#5 above. StoredRoles is then returned as a List of RolesId (Number).

8. A valueChangeListener method is called on selecting/un-selecting the SelectManyCheckBox component.


Here, getSelectedRow method returns the selected row in table. Using this we can populate the SelectedRoles attribute with the value returned from the SelectManyCheckBox component. Then the selected row keys is saved in a pageFlowScope variable which will be used to commit the data.

9. On clicking of the Commit button, all the data is saved in the database as shown:


I tried getting all the selected row keys using the getSelectedRowKeys() method on table with RowSelection=multiple. But it was returning only the last selected row key. Therefore I have to use the pageFlowScope approach.

Sample Workspace:
Download the sample workspace from HERE.

Sunday, June 17, 2012

Format: Date and Number fields in table

To format a date field on UI, use <af:convertDateTime>.
For example, if a date has to be displayed in 12-Jan-2012 format, use convertDateTime as below:


Output:


Similarly to format a number field on UI, use <af:convertNumber>.
For example, if the salary of an employee has to be displayed in 12,000 format, use convertNumber as below:


Output: