Domain Portal

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Sunday, 4 May 2008

ADF Faces Rich Client - Complex Validation

Posted on 01:53 by Unknown
Hey, my first application with JDeveloper 11g TP4 ! :-)

During this week I was working on business rules implementation design in my project. I got one really not usual business rule for UI, the thing is that client is Oracle Forms customer. So, in general this business rule was defined like - "When validation for particular field is failed, user must be not allowed to move to other fields". If you have noticed, in ADF Faces RC by default users are allowed to move focus to other fields and enter data, even if validation for some field is failed.

I was trying to use direct DOM manipulation to implement this rule, but without success. I have discussed this with Frank Nimphius (Principal Product Manager in Oracle) and he suggested working solution based on ADF Faces client framework. Actually I will document it in this blog post. Also you can read ADF Faces Rich Client - JavaScript Programming Nuggets page from Frank Nimphius blog.

I have implemented described business rule in ComplexValidation.zip sample application. Mandatory validation rules are applied for 3 fields - Last Name, Email and Job. Field - Job, contains LOV component and is associated with description text field - Job Title. And finally, application contains one optional Number type field. Sample is based on HR schema.

As you have noticed, there are 3 cases for validation in developed application - Mandatory, Mandatory LOV and Number type. You can easily implement your own rules, if will follow described techniques. Let's describe complex validation implementation steps for all 3 cases.

JavaScript code in all three cases will be written in af:group section created in af:document metaContainer facet:


1. Mandatory field

Rule description: When value is set to NULL and Tab button is pressed or mouse cursor is moved, focus must be returned back to Mandatory field where validation fails. To lock focus, JavaScript function is used, where ADF Faces client framework method is invoked:


Logically thinking, this function must be invoked when user is trying to move focus from current field with failed validation. With ADF Faces RC you can use af:clientListener operation component.


This component allows to invoke JavaScript function based on event. In our case, JavaScript function will be invoked when component loses focus - on blur:


At runtime, if value for mandatory Last Name field is removed:


Focus will be locked for Last Name field:


User will not be able to change values in other fields or press any buttons available on the page. The same applies for Email field.

2. Mandatory LOV field

Rule description: When value is set to NULL and Tab button is pressed or mouse cursor is moved, focus must be returned back to Mandatory LOV field where validation fails. Description text field associated with LOV field must be cleared, when validation in LOV field fails. In this case, I have used af:serverListener operation component additionally:


af:clientListener is defined similar like in previous case:


For af:serverListener I have provided its name in Type field and have specified method name from Backing bean. handlerMethod() is a Java method and this method will be invoked from JavaScript function in order to set empty value for description text field:


JavaScript function code:


Java method code:


Value of description text field in this sample application is binded to a method in backing bean:


Method in Backing bean provides value for description text field according to a value set from handlerMethod():


At runtime, when user clears value in mandatory LOV field:


Focus will be locked for this mandatory LOV field and associated description text field will be cleared. And of course, validation error message is displayed:


If you don't know already, nice feature of LOV component is that LOV window is opening automatically when wrong value is entered and Tab button is pressed (when AutoSubmit=True):


Tab button is pressed and LOV window is opened, since non existing value was entered originally:


When correct value is selected, associated description text field is refreshed again and user can move focus to other fields:


3. Number type field

Rule description: Focus is locked, when invalid value is entered. This rule is implemented in similar way as a rule in first case. JavaScript function is different:


When wrong value is entered, focus is locked again and validation error message is shown:

Read More
Posted in ADF, JDeveloper 11g | No comments

Friday, 2 May 2008

Oracle Rocks Again - JDeveloper TP4

Posted on 01:58 by Unknown
Just about hour ago I have downloaded and extracted JDeveloper TP4. My first impression is very positive. I have noticed those changes so far:
  • Tool UI (functional and graphical) is improved, this will allow to develop even more quickly.
  • Tool performance is improved. Dialogs and Design windows are working faster and embedded OC4J start time is reduced.
  • Oracle ADF Faces Rich Client components behavior is improved. When running developed application, components are opening and closing in more nice way.
  • And of course, bug fixes and one more time bug fixes.
In my notebook (Apple MacBook Pro, 2.5 GHz Core Duo, 4 GB, Win XP through Boot Camp), JDeveloper TP4 runs as quickly as common Windows application.
Read More
Posted in JDeveloper 11g | No comments

Sunday, 27 April 2008

Record Split Into Table and Form

Posted on 01:53 by Unknown
Those familiar with Oracle Forms, probably know how often in Forms is used UI interface pattern, which splits record into table and form. Simply speaking, one part of record attributes is displayed in table component and second part of attributes is displayed in form component. In Oracle Forms it is usually done for long records with many attributes in order to save space in visual form layout.

You can download sample where this approach is implemented - ADFTableForm.zip. Its simple sample and main trick here is not to forget to specify PartialTriggers property for dependent form element. PartialTriggers must point to parent table Id name:


This means when user will select row in parent table, dependent form will be updated with data from selected record. This action is done automatically in ADF, you just need to use attributes from the same Data Control element.

In developed sample application, when user selects row in a table, Salary and Phone Number fields in dependent form are updated with values from selected row:


Create functionality works as well. When Create button is pressed, empty row is displayed in parent table and fields in dependent form become empty:


User can cancel Create action with Cancel button. Cancel functionality is implemented with Rollback action dropped from Data Control.
Read More
Posted in ADF | No comments

Sunday, 20 April 2008

Validated Data Types with Domains in Oracle ADF

Posted on 10:28 by Unknown
I was blogging about use of domains in ADF Business Components previously - Oracle Object Types in Oracle ADF. However, I have described domains there from Oracle Object Types implementation perspective, but its possible to use domains for validation rules. With domains you can implement custom validated data types for java.lang.String, java.lang.Long and other Java types. Main benefit of validated data types implemented with domains is reusability. Let's say if there are attributes in several Entity or View objects and the same validation rule is applied for those attributes, its more wise not to repeat this validation rule, but to put it into domain. I will explain in this post, how to do this.

You can download developed sample application - ADFDomainValidation.zip. To run this sample, you need to have standard HR schema in your database, I'm personally using Oracle XE. Just right click faces-config.xml file and select Run, application will be started.

I have implemented domain called - SalaryDomain. This domain is based on java.lang.Long type and it validates for positive salary amount.


When JDeveloper generates domain, Java class for this domain is generated as well. This class contains standard method - validate(). You can put your validation code here. Its important to notice, that validation logic will be applied for existing and for new data. This means validation is applied during querying from database process. I have implemented simple validation rule - salary value can't be negative:


And now, when domain is created and validation logic is implemented, we can apply our domain as a Type for attributes. Applying domain for MinSalary and MaxSalary attributes from Jobs Entity object:


Applying domain for Salary attribute from Employees Entity object:


So, you can notice the same validation logic is applied for three different attributes in two different Entity objects.

When application is running and user is trying to assign negative value for MinSalary attribute:


Valdation error message is shown:


And if user will provide negative value for Employee salary:


The same validation error message will be shown:

Read More
Posted in ADF, JDeveloper 11g | No comments

Monday, 14 April 2008

JDeveloper 11g Masterclass in Vilnius - After Event

Posted on 10:52 by Unknown
Today I was participating in workshop - Oracle Forms: The Road To SOA, this event is described in my previous blog post. I have done JDeveloper 11g Masterclass session during this event, it was 2 hours session and was based on functionality described here. Event was successful with about 50 people auditory.

During my session I have developed 2 applications. You can download those applications I have developed on the fly and run with JDeveloper 11g Technology Preview 3 - Forms2SOA.zip and FormsToSOAComposite.zip. First application is main application based on standard HR schema from Oracle XE database. Second application implements ESB flow to write into file and is exposed through Web Service.

Here is Model part structure I have developed:


ViewController part structure is a little bit more complex:


I have designed Page Template with Panel Splitter component. You can see in Job Tab LOV component, in the second part of Panel Splitter is created Region with Employees table implemented as Fragment:


When value from LOV component is selected, table is automatically updated with Employees with selected job.

In the second tab - Job Edit, we can edit job selected from LOV component. This functionality is implemented in Fragment as well and comes to main page as Region:


However, this second Region is more complex, it provides a choice to display Graph component as well:


Fragment with Graph is displayed based on conditional logic, if Show Graph check-box is selected - Graph is shown:


Developed SOA composite is based on 3 parts - Exposed Web Service, Mediator and File Adaptor:


Exposed Web Service is invoked from application developed with Oracle ADF. File Adapter writes data received through Web Service to a file in File System.

Before you will invoke developed SOA Composite in your environment, you need to change WSDL location in DataControls.dcx file, available in Forms2SOA application:

Read More
Posted in Events, Forms, JDeveloper 11g | No comments

Monday, 7 April 2008

Back to Athens

Posted on 09:43 by Unknown
I'm already was in Athens some months ago, but this week I'm back again - doing Oracle ADF consulting. It's always nice to come back here, seems it's summer :-)

Read More
Posted in Traveling | No comments

Wednesday, 2 April 2008

CRUD implementation with JDeveloper 11g

Posted on 04:16 by Unknown
In this post I want to describe how its possible to implement Create-Read-Update-Delete (CRUD) functionality with JDeveloper 11g. There are many approaches that can be used to implement those functions with JDeveloper 11g. Today I will describe how to develop form based CRUD functionality.

Main advantage of developed sample application - ADF11_CRUD.zip is that CRUD functionality is implemented with Regions and based on ADF Task Flow. This allows to implement logic in separate forms, but to present to user with one page. Regions and ADF Task Flows are features introduced from JDeveloper 11g, in previous releases it was possible to implement CRUD functionality with forms in separate pages or to play with forms rendering using one page. However, both approaches weren't ideal, since users usually don't like to navigate from page to page and on the other hand to implement full functionality inside one page was potential source for bugs.

I have designed ADF Task Flow in my sample application:


Page fragment that is opened first, when running defined task flow is - departments. This fragment contains Master information for Detail part accessed in subsequent pages. Implemented page fragments are aggregated by ADF Task Flow and registered to be used in main.jspx page as Region. ViewController layer structure, one JSPX page and four fragments:


When you will run sample application, main.jspx will be opened and you will see departments fragment:


Here you can choose one of the Departments and go to Detail part - Employees CRUD functionality. User still will be on the same page, however new fragment will be opened - employeesUpdate:


From here we can involve Create functionality in employeesCreate fragment:


You can notice that JobId is read-only in this form, it's because I'm assigning default value for this attribute. However, it can be changed later. JobId is assigned from value stored in #{processScope.JobId}:


When new employee is created, employeesUpdate fragment will be opened automatically. Here you can update employee information:


And finally, when Delete button is pressed, confirmation fragment for Delete action is opened:


Delete action is invoked from Backing bean, I'm using removeCurrentRow() function to remove row from iterator:

Read More
Posted in ADF, JDeveloper 11g | No comments
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Popular Posts

  • 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 calcu...
  • External Transaction Service in Oracle TopLink
    I have developed sample application, in order to demonstrate how to use External Transaction Service (ETS), when Oracle TopLink is used in M...
  • Many-to-Many mapping in Oracle TopLink
    This kind of mapping in relational world is constructed using three tables. However, in object world only two classes are used for many-to-m...
  • Multi-selection feature and ADF Faces af:table component
    In this post I will describe how to use multi-selection feature in ADF Faces. First of all I should say - multi-selection feature is fully s...
  • Oracle JDeveloper/ADF Developers Wanted
    In my current Oracle JDeveloper/ADF project we are searching for additional developers. Project is based on Oracle Fusion 11g, so it can be ...
  • 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...
  • Oracle Spatial and Network Data Model
    During this week, a student from university where I'm achieving my master degree - Vincent, have asked me how to create SDO network dat...
  • Customizing Applications with MDS - Practical Overview
    During ODTUG Kaleidoscope 2008 , I was discussing with Shaun O'Brien (Principal Product Manager from Oracle Development Tools group) abo...
  • 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 b...
  • 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 ...

Categories

  • ADF
  • Apex
  • Apple
  • BPEL
  • Events
  • Forms
  • Groovy
  • JDeveloper 11g
  • Nomination
  • ODTUG Kaleidoscope
  • OFUG
  • Oracle Magazine
  • Oracle OpenWorld
  • Security
  • SOA
  • Spatial
  • TopLink
  • Traveling
  • Uncategorized
  • Vgo Software
  • Web Services
  • WebCenter
  • WebLogic
  • Workarounds

Blog Archive

  • ▼  2008 (72)
    • ▼  December (2)
      • Groovy - Multiple LOV's per Attribute in JDevelope...
      • After UKOUG'08
    • ►  November (3)
    • ►  October (9)
    • ►  September (4)
    • ►  August (9)
    • ►  July (6)
    • ►  June (10)
    • ►  May (4)
    • ►  April (5)
    • ►  March (7)
    • ►  February (5)
    • ►  January (8)
  • ►  2007 (65)
    • ►  December (6)
    • ►  November (7)
    • ►  October (6)
    • ►  September (4)
    • ►  August (3)
    • ►  July (4)
    • ►  June (6)
    • ►  May (5)
    • ►  April (6)
    • ►  March (4)
    • ►  February (5)
    • ►  January (9)
  • ►  2006 (9)
    • ►  December (9)
Powered by Blogger.

About Me

Unknown
View my complete profile