Saturday, December 27, 2008

Bug in Create/Edit View Criteria Wizard (JDeveloper 11g)

There is one (known) funny bug in Create/Edit View Criteria wizard (ADF BC 11g, View Object), I will describe it today. Bug I'm describing today is related to Bind Variables defined while declaring View Criteria in ADF BC View Object. For some reason, wizard can loose correct names for Bind Variables and reassign wrong ones, this will cause unexpected behavior on runtime.

How to reproduce:
  1. Open your View Object, go to Query section and click Create new view criteria sign. Create View Criteria wizard will be opened
  2. In Edit Query Criteria tab, press Add Item button. As Attribute choose EmployeeId and for Operand select Bind Variable option
  3. Press New button, available next to Parameter field
  4. In Bind Variable wizard, provide employeeIdVar for Name and Number for Type. Press OK
  5. Press OK in Create View Criteria wizard - EmployeesViewCriteria is created and Bind Variable is defined as well. So far its okej
  6. Now let's say we will want to modify our View Criteria. Click Edit selected view criteria sign for EmployeesViewCriteria. Edit View Criteria dialog will be opened
  7. Press Add Item button and change Attribute for added item to FirstName. For Operand slect Bind Vraiable option
  8. Press New button, available next to Parameter field
  9. In Bind Variable wizard, provide firstNameVar for Name and String for Type. Press OK
  10. Everything looks okej, so press OK in Edit View Criteria wizard in order to update EmployeesViewCriteria
  11. Save your View Object
  12. Now, reopen Edit View Criteria wizard by clicking on Edit selected view criteria sign
  13. I know, you will be surprised now, but you will see that for FirstName item is assigned employeeIdVar Bind Variable. Here is a Bug - correct Bind Variables are not stored correctly, simply first one from the list is assigned after you closing Edit View Criteria wizard:

This means, if developer will forget to fix this, on runtime same Bind Variable will be used for both parameters. In this case Number type Bind Variable is assigned to String type parameter.

On runtime, when user will select value for EmployeeId parameter, same value will applied for FirstName parameter:

WHERE part of SQL statement looks pretty funny as well:

WHERE ( ( ( ( Employees.EMPLOYEE_ID = :employeeIdVar ) OR ( :employeeIdVar IS NULL ) ) AND ( ( UPPER(Employees.FIRST_NAME) LIKE UPPER( :employeeIdVar || '%') ) OR ( :employeeIdVar IS NULL ) ) ) )

Workaround (not smart enough):
  • If you are using Edit View Criteria wizard and adding new Items with new Bind Variables, always reopen (after first change) this wizard and check if Bind Variables are not reassigned. If they are, change them back and close wizard - next time reassignment for already defined items will not be done

Spanish Summary:

Titulo: Bugs en el asistente de Jdeveloper 11g cuando se crean formularios de ALTA y EDICION.

Resumen: En este post se reproduce un error que genera el asistente de jdeveloper cuando se construyen formularios. Este articulo incluye la manera de solucionar este inconveniente.

Friday, December 26, 2008

Bug in ADF Task Flow and ADF Query Component Combination

In our project, we have faced interesting bug, I will describe it in this post. This bug is related to three elements - ADF Query Component, ADF Task Flow and Page Definition. Basically speaking, we have two pages in our application, when opening second page from first and closing it - first page wasn't rendered correctly. At first, we were thinking something wrong with our Close button in second page - however after investigation we didn't found anything wrong with it. After all, we did some crazy tests and found the reason of a problem we were facing.

Problem description:
  1. Application contains two ADF Task Flows. Both ADF Task Flows are with Data Control Scope set to Isolated. First ADF Task Flow implements call to second, second returns back to first using Task Flow Return activity
  2. First ADF Task Flow contains JSF page with ADF Query component. ADF Query component property Disclosed is set to True
  3. Second ADF Task Flow contains basic JSF page with Close button. This page must have associated Page Definition file
To reproduce:
  1. From first page with ADF Query, open second page. Press Close button - you will return to first page. Repeat same action couple of times, while returning to first page you will get incorrectly rendered screen
We have spent quite a lot of time in order to understood the reason for this problem. Finally, we have noticed, problem gone when Page Definition for a page contained in second ADF Task Flow was removed. That sounds really strange, but it works like this. However, later I understood, main reason is ADF Query component. For some reason, this component is rendered in wrong way, when returning from ADF Task Flow with Data Control Scope set to Isolated.

  1. Set Disclosed property to False for ADF Query component. This means, ADF Query will not be rendered when page will be opened and error will not appear
  2. For second ADF Task Flow, set Data Control Scope to Shared. Yes, this works well. For some reason, when second ADF Task Flow is using same data control instance as a first one - ADF Query component is rendered correctly. It works even with Disclosed set to True.
I personally, would like to recommend second approach, if you are not managing transactions.

You can download sample application, where you can reproduce described bug -

Sample contains first ADF Task Flow from where second is called:

Second ADF Task Flow contains Task Flow Return activity:

Data Control Scope is set to Isolated:

On runtime, when first ADF Task Flow is opened:

Press Job List button, second ADF Task Flow will be opened:

Press Close button, if you will not get error from first time, repeat same steps for 5-6 times and you will get it:

Page is rendered incorrectly and error is generated:

This error, is system error related to ADF Query criteria.

When Data Control Scope for second ADF Task Flow is set to Shared, it works well.

Spanish Summary:

Titulo: Bugs en el uso combinado de ADF Task flow and ADF Query Component.

Resumen: En este articulo, Andrejus muestra otro bug que tiene la herramienta, la cual se produce cuando se utiliza varios ADF Task Flow que muestra los mismos resultados basados en una consulta de datos. La solución finalmente radica en que ambos task flow compartan el mismo DataControl.

Monday, December 15, 2008

Cascading LOV's in Oracle ADF 11g Update 1

I was very happy, when have noticed that Oracle have fixed null value bug in LOV component, I have described couple of weeks ago. This bug is fixed in newest JDeveloper 11g release - JDeveloper 11g Update 1. At first, this bug looks quite funny, however it was affecting lots of functionality related to LOV components. One of such examples is Cascading LOV functionality, previously it simply wasn't working, since it was impossible to assign null value to child LOV, if parent LOV value was changed. Now it works fine.

I have developed and posting sample application for Cascading LOV's, you can download - Cascading LOV's in 11 are simple, you just need to define View Criteria on dependent LOV component and specify Bind variable. Usage for Bind variable should be specified as Required:

While you will define Bind variable, don't forget to set Display Hint for this variable to Hide. This will allow to hide Bind variable in LOV component and not to render it on UI:

Finally, when you will define LOV for View object attribute, in View Accessor select defined View Criteria and specify value for Bind variable, this will ensure cascading relationship:

In ViewController, don't forget to set AutoSubmit = true for parent LOV's and PartialTriggers for dependent LOV's, you can set EL expression for Disabled property. You will need to create Value Change Listener methods for parent LOV's as well. Those methods will clear values in dependent LOV components:

On runtime, it works pretty nice, here is an example parent LOV and two cascading LOV components. Third LOV is dependent on second and first:

When value in first LOV is selected, second LOV becomes enabled:

Value in second LOV is selected, third LOV becomes enabled:

Finally, value in third LOV is selected:

If parent LOV value is cleared, all dependent LOV's are cleared also, it wasn't working before:

Spanish Summary:

Titulo: Listas de Valores en cascada en ADF 11.

Resumen: Este capitulo muestra como construir listas de valores dependientes una de otra como el clásico (PAIS - DEPARTAMENTO). Andrejus destaca la solución de un bug que tenia esta funcionalidad pero que ha sido solucionada en la versión reciente de la herramienta.

Sunday, December 7, 2008

Groovy - Multiple LOV's per Attribute in JDeveloper 11g

I was blogging previously about multiple LOV's per attribute functionality. I was using RowImpl class for View object in order to calculate value for LOV switcher attribute. However, this approach is not perfect, since it requires to create Java implementation class with getter method. Even more, getter method in RowImpl class is not invoked, when LOV component is triggered in ADF Query Criteria component. I have described this cool component in my previous post - ADF Query Component and View Criteria Functionality with Custom Query Listener in 11g.

So, as you probably already understood, I will show better approach for LOV switcher attribute implementation with Groovy language expression, defined as a Value for transient LOV switcher attribute.

You can download developed sample application - This sample as all my samples is based on standard HR schema available in Oracle XE. This application is based on previous sample. Only one addition here is LOV switcher attribute with Groovy expression, that allows to render different LOV components on runtime, based on data values.

I have defined two LOV components for DepartmentId attribute. One LOV component will show two columns and second will show three columns with data:

As you can see, there is transient lovSwitcher attribute defined. This attribute will switch LOV's for DepartmentId attribute. This time, I'm using Groovy language expression as a value for transient attribute. This allows me to have multiple LOV's functionality even in ADF Query Criteria component. With switcher implementation in RowImpl class getter method, its not working. So, here is my transient attribute with Expression defined as a Value Type:

And here is actual expression, it checks Salary attribute value and returns first or second LOV component name to be used:

On runtime, if I will provide value 8500 for Salary criteria, for DepartmentId I will get second LOV with three columns in ADF Query Criteria and same in results table - correct logic:

If in ADF Query Criteria I will provide 4000 for Salary criteria, for DepartmentId I will get first LOV with only two columns:

Same functionality works in results table, based on Salary value contained in current row. So, I would recommend you to use Groovy for multiple LOV's implementation instead of Java getter methods in RowImpl.

Spanish Summary:

Titulo: Uso del lenguaje Groovy para la creación de Lista de Valores en JDeveloper 11g.

Resumen: Andrejus muestra como crear listas de valores en JDeveloper 11g haciendo uso del lenguaje Groovy.

After UKOUG'08

This week I was on UKOUG'08 conference. I really have enjoyed high quality of its content and I have learned new technical things about JDeveloper/ADF 11g and ADF Business Components performance tuning.

Myself, I did two sessions. First one was - Oracle Maps and JDeveloper 11g - Perfect Combination. It was Masterclass type demo on the fly, I have developed working application in front of auditory. And, there was no errors or exceptions, I really enjoy such kind of sessions. I believe I can better share knowledge with live demo, comparing to dead slides. And most important, auditory likes such kind of sessions.

Second session was - ADF Task Flow - Based On Practical JDeveloper 11g Experience. For this session I was using already prepared sample application and have described how it was build. Again, there was no errors or exceptions on runtime. I was focusing on ADF Task Flow functionality we are using in my project, I didn't wanted to explain all ADF Task Flow features. I have covered following items:
  1. Method Call
  2. Router
  3. Transaction Management
  4. Error Handling
  5. ADF Library
  6. ADF Query
  7. ADF Security
Spanish Summary:

Titulo: Después del evento del Grupo de Usuarios del Reino Unido

Resumen: Andrejus describe su participación en el último UKOUG, el cual es un evento realizado por el grupo de usuarios de Inglaterra.