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.

Workarounds:
  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 - ADFBugTaskFlowQuery.zip.

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 - CascadingLOV.zip. 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 - ADFSearchApp2.zip. 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.

Thursday, November 27, 2008

Workaround for Null Value Bug in ADF List Of Values 11g

Those of you, who are using List Of Values (LOV) component in ADF 11g, most probably already have noticed bug related to Null value. Simple description - if any non Null value is set for LOV, it is impossible to set Null value (for non-mandatory LOV's). This bug is known for Oracle, and I'm sure they will fix it in next build. For now, there are two paths for us. First is to ignore it, and test with next build, when it will be available. Second is to apply temporal workaround, until bug will be fixed by Oracle. In my opinion, you should follow second path, if you have critical need to be able to set Null value for LOV before next build will be available from Oracle. In this post, I will describe this workaround, relatively very simple one.

You can download sample application, with implemented workaround - LOVNull.zip. This sample contains basic form, with one LOV component for DepartmentId attribute:


So, the problem is with Null value in LOV component, basically Null is not accepted. This bug is not related to the Model, because if you will test with ADF BC Browser, it works well. Bug is related to View layer. This means we can invoke exposed method in View object and set Null value for LOV attribute programmatically. To achieve this, I have created my custom method in View object class and exposed this method through Client Row interface:


Exposed custom method clearLOV(), basically invokes setter method for DepartmentId attribute and provides Null.

In View layer, for my LOV component, I have set AutoSubmit=true property and provided ValueChangeListener in order to check when user will try to provide Null value:


ValueChangeListener compares new LOV value to Null, and if user is trying to set Null, exposed custom method is invoked trough bindings to set Null value programmatically:


And how it works? Let me at first to show how it works without workaround. Here we have a form with LOV component, by default value is not set for LOV:


Let's set provide any non Null value:


And now, when LOV value is stored in database, let's try to clear it:


Press Save button to store our last change and you will get previous value back - Null (or empty) value is not accepted anymore:


However, if you will use described workaround, Null value will be set as expected:

Wednesday, November 19, 2008

Hints for ADF 11g Application Credential and Policy Migration to Standalone WebLogic Servers

Recently I was deploying our ADF 11g application on standalone WebLogic server. Deployment itself is straightforward, however it is little bit more complex with security metadata migration from development environment to test environment. I have migrated application credentials and policy data using steps described in Steve Muench document - Simplified ADF 11g Application Credential and Policy Migration to Standalone WebLogic Servers. This document is very clear and useful, I would recommend to read and use for everyone who will face problem with security metadata migration to standalone WebLogic.

So, after you will read Steve's document, probably you will find those my 2 hints useful as well:

1) Even if you are not using ADF Security in your application, still in the most of the cases you will need to migrate application credentials. You will need to do this, if you are using JDBC URL as Connection Type to database, since database connection credentials are stored in credentials file. There is no need to migrate application credentials if you are using JDBC DataSource instead of JDBC URL. If credentials for JDBC URL Connection Type will not be migrated, most probably you will get similar error on runtime - Incomplete connection information:


2) After you will succeed to migrate application credentials and policy to the test environment, this doesn't mean you will be able to run your application immediately (in a case of DD Only Security Model). Its because system-jazn-data.xml available on standalone WebLogic is populated with users and policies from development environment, however those users are not mirrored to standalone WebLogic. This means, authentication step will not be completed.

In order to solve this issue, you can go to WebLogic console and in Security Realms (myrealm by default) you can define users you want to authenticate. There is no need to define roles for those users, since authorization will be done based on policies stored in system-jazn-data.xml available on standalone WebLogic after migration.

Saturday, November 8, 2008

ADF Query Component and View Criteria Functionality with Custom Query Listener in 11g

Nice new component in ADF 11g is ADF Query - af:query. This component allows to implement Search functionality in your applications with much smaller effort comparing to Search functionality implementation in 10g. In conjunction with View Criteria, ADF Query provides declarative way for Query Criteria forms development. There is no need anymore to have transient attributes for Query Criteria, since we can base it on View Criteria attributes from View object. In this post I will describe how you can implement user-friendly Search functionality in 11g and how to use custom QueryListener for ADF Query.

You can download developed application - ADFSearchApp.zip. This application provides sample page with ADF Query component and results table. Additionally, this application contains custom behavior - when there are pending changes in results table, re-query is not performed and user is forced to commit or rollback existing pending changes.

Good news about ADF Query - it can use List Of Values defined in Model layer. So, if we have List Of Values declared for DepartmentId attribute:


DepartmentId in ADF Query automatically will appear as List Of Values, since this attribute is declared in View Criteria on View object:


Sample page contains two main components - af:query and af:table with ID = resTab. First component implements ADF Query and second - table for results:


If you will select af:query component in Structure view, Property Inspector will show you all properties of af:query. You should pay attention to ResultComponentId property, its Id that points to component where Search results will be shown. Most important thing in my sample application - custom QueryListener processQuery(). I have created it custom, because I want to control query execution and not to execute query when there are pending changes in results table:


However, custom QueryListener declaration is not enough in order to control query execution regarding pending changes. Additionally, you need to set PartialTrigger on results table and point to ADF Query. This is needed in order to auto submit results table and inform Application Module about pending changes before executing query:


Created custom QueryListener is simple - if there are pending changed, query is not invoked, if there is no - standard QueryListener is invoked. Information about pending changes is retrieved from Application Module, using isDirty() function:


On runtime, you will see such screen - Query Criteria area and results table:


DepartmentId List Of Values is shown, you can use it to provide search criteria parameter:


Results table is populated and if user will decide to change for example HireDate column value:


And re-execute query with new query criteria for DepartmentId:


There will be pending changes message shown, since user didnt saved his/her last changes before re-executing query. When user will save pending changes and will query again, it will be successful:

Monday, October 27, 2008

Oracle Day'08 in Vilnius

During this week, on October 30th, Thursday, there will be Oracle Day'08 event in Vilnius. Its a traditional Oracle event in my country, mostly for a local Oracle market. Information about how to register and attend, you can find on the official Web page.

Event schedule is mostly in Lithuanian language, however by number of speakers and sessions you can see how strong Oracle technology is in Lithuania.

Myself, I will deliver 1 hour session Oracle Maps in JDeveloper 11g - Perfect Combination. This session will be based on material I have presented during Oracle Develop at Oracle OpenWorld'08 in San Francisco.

See you there !

Saturday, October 25, 2008

After BGOUG Autumn' 2008 Conference

Going back home after my session on BGOUG'08 in Bulgaria, Bansko. As usual, delays in airport.

In Bulgaria, I have explained how developers can use ADF Search component and refresh results table together with graph component at the same time. Additionally, I have described how to use ADF Security with wizards and authorize user based on his role.

Here is a sample screen of application I have developed on the fly:


Tomorrow going to Riga for JDeveloper/ADF 11g Masterclass workshop, really busy time... :-)

Wednesday, October 22, 2008

ADF Security 11g and ADF Business Components

Looks like in JDeveloper 11g, ADF Security works as it should work. In this post I will cover ADF Security part, related only to ADF Business Components. For example, Oracle Business Component Browser can be used now to test security configuration in Model layer. It wasn't working in 10g and in 11g Technology Preview builds, however in Production it works!

Now, if you will run secured Application Module with Oracle Business Component Browser, you will get authentication dialog:


This dialog was raised in previous JDeveloper builds as well, however authentication never was passed, it works now.

You can download my sample application - ADFSecurity.zip. This sample is configured with ADF Security and contains 3 users (all with welcome1 password):
  • john (role: clerk)
  • susan (role: manager)
  • steve (role: developer)
Sample application contains one Entity object - Jobs. This entity is secured for update action:


Two roles are authorized to update on entity level - manager and clerk:


Additionally, JobTitle attribute is secured for update action:


This action is authorized only to manager role:


If you will run Application Module with susan (role: manager) user:


All entity attributes will be available for udate:


With john (role: clerk) user:


All attributes except JobTitle can be updated. It happens, because only manager role is authorized to update JobTitle attribute:


If Application Module will be tested with steve (role: developer) user:


User will not be able to update any attribute, since this user is not authorized for update action: