Tuesday, January 30, 2007

More bandwidth available ;-)

Bandwidth limit problem has been fixed - all samples are moved from Google Pages to Vilnius University, Faculty of Mathematics and Informatics server. In this university I'm achieving my Master in Computer Science degree. Hope, download of all samples will work ok.

The bandwidth limit has been exceeded

Upss..., it seems how-to applications are really popular, Google Pages service gives - 'The bandwidth limit for this site has been exceeded'.


So, now I'm searching for a new service provider who will host my sample applications. Sorry for temporal troubles, samples will be available soon.

Saturday, January 27, 2007

J2EE Container-Managed Authentication

It was quite long ago, but I still remember my first work with J2EE container-managed authentication. However, now it is more easy, authentication implementation using JDeveloper 10.1.3.1 becomes very simple thing. In fact, there is only two places where authentication related information must be declared to activate authentication process - jazn-data.xml and web.xml files. Below I will describe how to do this and also how to use this.

I have developed sample application - Authentication.zip, which use jazn-data.xml and web.xml files for the authentication logic implementation. This application is developed based on material available in Oracle Application Development Framework Developer's Guide 10.1.3 and Oracle Application Development Framework Tutorial 10.1.3.1. I have tried to aggregate information available in those documents and show how authentication can be used in ADF.

The first thing you should do when enabling authentication for your application is to declare users and their roles. In this sample, I'm using jazn-data.xml for embedded JDeveloper OC4J, to store users/roles. Detailed information about how to create jazn-data.xml and declare users/roles is available in Chapter 6 of Oracle Application Development Framework Tutorial 10.1.3.1.

When users/roles are declared in jazn-data.xml, edit your web.xml using JDeveloper wizard. Add there security roles as you have declared in jazn-data.xml, define security constraints, each constraint can have accessible URL Patterns and can be assigned to one or more roles. Final step is to define login configuration, in this sample I'm using HTTP Basic Authentication. Complete instructions about how to configure web.xml are available in Section 18.3.3 of Oracle Application Development Framework Developer's Guide 10.1.3.

For basic authentication it is enough to pass described two steps. However, if you want to use authentication related information for authorization implementation, you need to have a managed bean, this bean will acquire information from J2EE container and pass it through expressions to ADF Faces components. In my sample, information about user name and his roles is acquired in managed bean class constructor, managed bean also implements getter methods.

I'm using four users (all of them with 'welcome' password) and three roles:
  1. alex (developer)
  2. scott (tester)
  3. diana (developer, tester)
  4. john (manager)
Managed bean code for providing information about user and his roles is straightforward:


ADF Faces components can use authorization information in their properties through expressions like this - #{authRoles.manager}, where authRoles is a name of managed bean. Below I demonstrate results of using authorization information in ADF Faces components.

User with name 'diana' have two roles assigned, developer's and tester's panels will be displayed for her:


While to user 'john' is assigned only one role - 'manager', only manager's panel will be shown:

Monday, January 22, 2007

Forms developer in JDeveloper world at OracleBrains.Com

At OracleBrains.Com blog, I have found a series of posts about Oracle JDeveloper, that have been written by Oracle Forms developer. Those posts are published under - Journey of a Form Developer to JDeveloper World title. It sounds really cool, doesn't it?

I should notice, that it is a positive sign, it shows that people who have strong background in so called traditional Oracle technology (Oracle Forms, Oracle Reports, etc.) are looking or starting to look into J2EE also. In my opinion, those posts could be a good jump-start for 4GL folks, who are new in JDeveloper world.

Thursday, January 18, 2007

Accessing property file entry from ADF Faces bean

In some cases, developer need to access property file entries not only from expression language, but also from ADF Faces Backing or Managed bean code. There is nothing difficult, just notice, that message bundle must be specified in faces-config.xml

You can download sample application - AccessPropertyFile.zip, which shows how I'm accessing property file entries from Backing bean methods. There are two buttons on the application page and one text component. Entries in property file:
  1. firstAction=First action processed
  2. secondAction=Second action processed
Value for text component is retrieved from property file and depends on clicked button:


When developing described functionality, at first I have declared message bundle in faces-config.xml:
  1. Open faces-config.xml in JDeveloper
  2. Select Overview tab
  3. Choose Application option
  4. Declare property file in Message Bundle field (e.g. lt.andrejusb.resources.UIResources)
Second step was to create two af:commandButton components along with one af:outputFormatted, for both buttons action methods in Backing bean were generated. Code for action methods:


Entries in property file are accessed using function from JSFUtils class - getStringFromBundle(param). This become possible, after declaring message bundle in faces-config.xml. JSFUtils class source comes with standard JDeveloper sample application - SRDemo.

Saturday, January 13, 2007

Oracle Maps and ADF Faces af:table component

In this post I will describe how to develop spatially enabled data table using Oracle ADF. If you are new to Oracle Maps and want to know more about this product, you could check my previous post - JavaScript in ADF Faces - Oracle Maps, where I'm describing how to configure Oracle Maps and develop simple spatial application using Oracle ADF, also you will find links to external resources.

Business logic of developed sample - OraMapsWithTable.zip, is to provide a possibility of browsing through a table with cities data and to show selected city on the map. For the data source is used CITIES table from MVDEMO schema. Geometry theme for the CITIES table is declared using Oracle MapBuilder product. Oracle MapViewer, Oracle MapBuilder, MVDEMO schema and other spatial products you can download from - OTN. In the application Model layer EJB and TopLink are used, and ADF Faces components in the View layer.

Ok, if you have successfully deployed and configured MVDEMO schema, Oracle MapViewer and Oracle MapBuidler, it is time to describe how I have developed this sample application.

As you may notice, I'm using cities data, however cities geometry theme declaration doesn't come with MVDEMO. So, we need to declare it. You can declare it in the less than a minute, just use Oracle MapBuilder tool. There are two main things you should define, when declaring geometry theme for cities - hidden info field and query condition. In the hidden info field you should define all fields you want to show in pop-up window when city's point on the map will be clicked. In the query condition, data selection criteria is defined. More information on this topic is available in MapViewer User's Guide section - 8.3.1 Theme-Based FOI Layers. Shortly, cities geometry theme declaration for this application should look like this:


Application Model layer is generated using JDeveloper wizards, and there is no any custom code added. However, I have deleted default session definition and created - oramaps session definition with data source location pointed to jdbc/OraMapsDS data source.

Application View layer contains cities table and map image. Cities table row selection is implemented using af:commandLink component for #{row.city} field. Partial submit is enabled on af:commandLink and partial trigger points to af:panelHorizontal that contains map image. There is no any action or action listener defined on #{row.city} field, for map image update is used JavaScript onclick functionality onclick="showCity(#{row.rank90})". You should notice, that in ADF Faces it is possible to pass value from binding expression, as JavaScript function parameter. showCity(param) function is used to display selected city, function logic is implemented using JavaScript Oracle Maps API. Function source:


I have tested this sample on standalone Oracle Application Server (deployment profile is included into application workspace). Finally, we have a table and a map:


Let's say, we select Milwaukee city in the cities table, then similar map will be displayed:


So, what is better - to have a table or to have spatially enabled table? ;-)

Saturday, January 6, 2007

JavaScript in ADF Faces - Oracle Maps

Inspired by Jeroen van Schaijk article, I have developed simple application with Oracle Maps functionality, that shows how it is easy to use JavaScript in ADF Faces JSPX page. OraMapsSimple.zip, is developed using steps described in tutorial supplied with Oracle Maps. To develop this application, I have used spatial MVDEMO datasource and Oracle MapViewer 10.1.3.1 Quickstart kit, both available on OTN.

Spatial datasource comes with detailed instructions and there was no problem to install it on my Oracle XE (XE supports spatial functionality). When you start Quickstart kit for the first time, Oracle MapViewer deployment process is completed automatically. You can find instructions in Quickstart readme file about how to open Oracle MapViewer homepage and then according to the tutorial - Learning Oracle Maps by Example (it comes with Oracle MapViewer), configure Oracle Maps settings.

So, what about JavaScript? Oracle Maps functionality is reached from JavaScript code, so we need to place a portion of JavaScript somewhere between ADF Faces components. It is quite easy, just include div element for map image and surround it using f:verbatim tag. Script for displaying a map is straightforward (do not forget to include oraclemaps.js, this script comes with Oracle MapViewer).


And, finally we have a map, that displays population density by counties:


With sample application comes deployment profile, which you can use if deploying to Oracle Application Server.

Tuesday, January 2, 2007

Countries boundary data in Oracle Database 11g

It seems, according to the document on OTN - Oracle FAQ: NAVTEQ Digital Map Data for Oracle and to OTN Forum post - Oracle & Navteq FAQ & Countries boundaries, that with Oracle Database 11g will be shipped countries boundary data provided by Navteq. Also, the same map data will be available on OTN for download.

Great! I think, it will be even more easier than now, for non-GIS people to start building BI applications with included Oracle Spatial technology functionality. Developer will have everything out of the box - from data to tools.

Monday, January 1, 2007

Multilanguage in fixed af:selectOneChoice ADF Faces component

If someone will face a problem how to enable multilanguage support in fixed af:selectOneChoice component, or simply how to bind fixed af:selectOneChoice elements to the property file, hope you will find an answer here. Sample application - FixedSelectOneChoice.zip, demonstrates how to solve this problem. This sample is based on SRDemo application SRDEMO schema, USERS table. In Model layer Toplnk and EJB are used and in View layer - implemented search form and results table are based on ADF Faces components.

For fixed af:selectOneChoice component is used Users entity, userRole element. userRole is used, because check constraint is enabled for this element on the database level - USER_ROLE IN ('manager','technician','user'). So, it is possible to use only those three constants. You might think - 'everything is fine, I will use simple fixed af:selectOneChoice as ADF Faces component for userRole element'. But, when fixed af:selectOneChoice is created using JDeveloper dialog - JSF component f:selectItems is used for af:selectOneChoice elements.


However, f:selectItems does not provide label/value setting functonality and there is no binding to property file elements. So, search form with by default created fixed af:selectOneChoice will look similar, for user role in dropdown list is used value stored in the database:


To modify default fixed af:selectOneChoice component and bind labels of it's elements to values available in property file, follow steps described below:
  1. Delete JSF component - f:selectItems from af:selectOneChoice in searchUser.jspx page
  2. Add four af:selectItem ADF Faces components into af:selectOneChoice with values - empty selection, 'manager', 'technician' and 'user'
  3. In searchUser.jspx page definition file delete list definition for userRole element. And, create attributeValues definition for userRole element with the same id and item value as it was defined in deleted list definition
  4. Create UIResources.properties file and declare three elements in it - 'Manager', 'Technician', 'User'
  5. Bind labels of af:selectItem components to elements declared in UIResources.properties file
Now, user role dropdown list labels are populated from UIResources.properties file, where multilanguage strings can be defined: