Tips & Tricks from Arun on JDev ADF, Forms, SQL & PL/SQL.

Monday May 21, 2012

In quite some cases, we would like to call the PUT method on a REST
service by constructing the parameters during runtime and pass it on. In
this article, we would go through how to deal with such cases when
building an ADF Application.

Refer this tutorial for introduction to REST service in where, GET and DELETE methods are explained. In this sample, we'll see how to implement PUT operation using a HashMap. In fact, as like in the above tutorial, we can directly execute the PUT method as well. This article is mainly concentrated on how to construct the parameters dynamically at runtime.

In
the above code, we find the loadData method from the DataBindings
entry, create a Map with all the required attributes to create an
Employee record, get the Parameter list for the method and pass the Map
to method as parameter to execute it.

Thursday Dec 29, 2011

JDeveloper 11.1.2.0.0 has a new tab in the View Objects Editor - Business Rules. This
easily tend to make people misunderstand that this Editor can be used
for adding validation rules for the attributes in the View Object.
However, it is not true.

Lets check out what this editor is all about. As the online help for this page statesUse
to create and maintain business rules based on Groovy Language
expressions and declarative validation rules for this view object
including:

Validators for transient attributes

Bind variable default value expressions for SQL queries

Bind variable value mappings for view accessors

Transient attribute value expressions

Transient attribute value expression recalculation conditions

Attribute default value expressions

We'll see how we can use this editor to edit different types :

Transient Attributes :

We can use this editor for a. adding validation rules, b. edit default value expression

a. As like the Entity Attributes, we can add many validation rules for the transient attributes in VO as well.

Ex.

In
the above image, EmpType is a transient attribute on Emp VO.We can see
there are two rules added. First one is a validation rule (List
Validator), restricting the user to enter either one of the value
specified for the attribute. Second one is the default value expression
for the attribute. Upon selecting the node, the default value groovy
expression would become editable in the Script Expression field below,
wherein we can modify it and test the syntax as well.

Note : We
can add the validation rule only for the transient attributes which are
Updatable. Also, we can edit only the default values which are script
expressions only. Not the literal values.

Bind Variables :

Similar
to the transient attributes, we can use this editor for modifying and
testing the default value expression for the Bind Variables of the VO as
well.

Ex :

In
the above example image, we can see a Bind Variable (Bind_Hiredate)
added to the Query, which has the default value expression as
adf.currentDate.

Using this editor, we can modify this expression and test the syntax.

View Accessor :

If
we have a bind variable to the VO and use it as List Data Source for
any of the attributes in the VO, we can use this editor to change the
value of the bind variable in the View Accessor.

Ex :

In
the above example image, we have couple of Bind Variables in the View
Accessors (they are used as Lists and Dependent Lists for this View
Object). Using this editor, we can edit the values of those bind
variables.

We can also use this editor for modifying and testing the default value expression on the VO attributes and the re-calculation conditions.

Monday Dec 13, 2010

When we build a web application which contains an ADF Table (with multiselect option), in many cases, we require to get all the selected rows to process through backing bean. This example will illustrate how to achieve that.

Assuming that we already have an application, that contains an ADF Table with multi-selection enabled (i.e the web page look something like the image shown below).

img empTableRT : Table based on Emp

To access the table in the backing bean (through command button click, for ex.), we add an attribute with accessors in the backing bean and bind it to ADF Table

Now, when we run the page, select 7 rows and click on the print button, it prints out

JONES
ALLEN
CLARK
WARD
SMITH
MARTIN
BLAKE

That is what we expected. Now, the question is why this happens?. It is because, since value of this selectedRowKeys property is #{bindings.EmpView1.collectionModel.selectedRow}, the selectedRowKeys will contain only the "row which is selected last". By unsetting this attribute, we let the table to push all the selected rows to selectedRowKeys, which will help us during

getEmpTable().getSelectedRowKeys();

in the backing bean. JDeveloper automatically adds this property to the ADF Table when it is created by dragging from the data control. So, removing this property from the af:table would get us desired result.