How To Create An Editable List Page in ADF 11g

For those of you wondering how my presentation turned out in Atlanta this past Monday, I can tell you, it turned out very well technically, but as far as attendance was concerned it wasn’t exactly an arena-sized audience. I think the user’s group itself is more centered around DBA’s which is typical for these types of events.

This post covers one of the basic techniques I demoed in my presentation on Monday. A simple editable list page. I will do a series of posts starting with this basic concept and expanding upon it in subsequent posts adding functionality as we go.

An Editable List Page

A common type of functionality in a lot of Oracle Forms applications is to have a list of records in a block and allow the user to edit those records, delete those records, and even create new records.

In ADF 11g, this would translate to a JSP page that allows you to list the rows in a View, edit and delete from those rows and also create new rows. This functionality is actually very easy to create.

Let’s go over it step by step.

1. Create a new application in JDeveloper (File -> New -> Application(Fusion App)

JDeveloper will use a template to create the basic project and file structures needed for an ADF application.

2. Create the necessary Business Components from Tables.

Right-click on the Model project JDeveloper created in the previous step. In the New dialog, open the Business Tier node and choose ADF Business Components. In the right pane, choose Business Components from Tables.

You will now need to create a new database connection. Click the New button where it appears next to Database Connection. Set the name to something appropriate and set the attributes accordingly. You can use the Test Connection button to insure it gets created correctly.

Click OK and you should be back at the ADF Business Componens Wizard.

Click the Query button to the right of the wizard and JDeveloper will return a list of available tables and views that you can create Entities from. Select Departments and move it over to selected, then click on the Next button.

The next screen is the Updateable View Objects Screen, move the Entity over to the “Selected” column. Press “Next” and take all of the defaults until you can click “Finish”.

Click the “Save All” button.

3. Create the JSP Page

Right click on the ViewController project. Select “New”.

From the left pane, choose Web Tier -> JSF, from the right pane, choose “JSF Page’. Click “OK”.

Give the page a name like departmentList.jspx (We use the x at the end to denote an XML compliant JSP page, but it isn’t necessary).

Once the page has been created, open the Component Palette. Make sure the component list is “ADF Faces”. From the layout pane, choose the panelHeader and drag it onto the page. Click on the properties panel and change the text propery to “Department List”.

From the right side of the IDE, in the Data Controls pane, open the AppModuleDataControl. Click on the DepartmentsView1 object and drag it into the panelHeader. Choose Tables -> ADF Table from the create menu that pops up. At the confirmation dialog check Sorting, Filtering, and Row Selection to enable these features for the table. JDeveloper will create a table on the JSP page.

Next, drag a panelGroupLayout component from the Component Palette over to the panelHeader. Click on the properties list and change the layout from scroll to horizontal.

Next, open the DepartmentsView1 node in the AppModuleDataControl, open the Operations folder, drag the CreateInsert button into the panelGroupLayout. Click on properties and change the name of the button to “Add”.

Drag the delete button from the Operations folder over into the panelGroupLayout.

Open the Operatons folder of the AppModuleDataControl itself, it will have two operations, Commit and Rollback. Drag them over into the panelGroupLayout next to the other two buttons.

Congratulations! You’ve done it. Right click on the JSPX file and choose Run to see your masterpiece in action. You should be able to add rows into the table, edit existing row, and delete existing rows. None of it will be persisted to the database until you click “Commit” and you can always “Rollback” all your changes. You should also be able to filter the table with the input boxes on top and Sort it with the little triangles on the columns.

If you play with this example you may notice a couple little “bugs” or “features”. In my next post I will discuss a couple of these and how to mitigate them.

In the following weeks I will be expanding upon this simple demo to include ADF Task Flows and creating separate pages for creates and edits as well as a Master-Detail page or two.

Share/Save/Bookmark

How Not To Prepare For a Demo

Well, it’s one of those weeks for me.  I have about a half a gajillion things to do and one of them includes preparing for a presentation on Monday.  I have had the presentation prepared for a few weeks now and I’ve even presented parts of it over the last month, but I haven’t done any part of the live demonstration yet.  In fact, besides having a vague idea of what I want to show I haven’t really had any time to figure out exactly what the demo is going to be.  Real professional of me, isn’t it?

I had put together what I thought was a solution for a common problem in converting forms to ADF.  I had done most of it on a plane from Connecticut to Austin, TX a few weeks ago.  I didn’t have a ton of time to test it before my laptop’s battery ran out, but it looked like it worked so I was counting on showing that solution during my presentation.  Unfortunately, now, 3 weeks later, and mere days before the presentation I loaded it up again and tried it out and it doesn’t actually work like I had hoped.

So here I am trying to figure out what is wrong with it and get it working, hopefully before Friday so I can run through it on Friday with some of the folks in the office before doing it live on Monday.

It isn’t the usual way I like to prepare for these things.  When doing product demos I have a machine dedicated to the demos that only gets updated when I know it works, especially since it frequently is used to show of “new” features that are in development, I like to make sure I have a script that works and that the environment is always the same.  Too many other things can go wrong to leave any of it untested.

Well, at least if there’s something I’m good at, it’s being able to come through under pressure.  Besides there’s always the flight to Georgia…

Share/Save/Bookmark

A Friday Afternoon Music Post - Alkaline Trio

I’ve been lax with the music posts lately, too many presentations to prepare and technical stuff to get done, so I thought I’d take the time to post something today and liven up the blog a littel bit. All this talk about Forms, ADF, and Java can get a little dry sometimes.

Alkaline Trio has been around for a while now, and in my opinion they haven’t exactly been getting better. They are a 3 member (big surprise, there, heh?) punkish rock band with some definite goth tendencies which have been emphasized a lot more in later albums which have also become a little more mainstream.

My favorite Alkaline Trio album is “Maybe I’ll Catch Fire.” It has a lot of catchy tunes that are somewhat dark and comic in nature. The song “F* You, Aurora” about a town in Illinois named Aurora in which there was a bad car accident that took the life of one of the band members friend’s. It includes the lyric s “…And although it’s all my fault, The blaming myself had to come to an end. So I say:F*** you Aurora, you took my only friend. You won’t catch me behind the wheel, Of a Chrysler ever again.” Matt Skiba has a flair for good lyrics.

My other favorite song on the album is simple entitled “Radio”. It is one of the best I-hate-you and wish-you-would-die type of songs out there. With lyrics including “I wish you, would take your radio to bathe with you, plugged in and ready to fall,” and “while you’re taking your time with apologies, I’m making plans for revenge,” it gets my vote for one of the best sing-along songs ever. Not that I’m bitter or anything, but everyone has a bad day every once in a while and just needs to get it out somehow, don’t you think?

Other albums I would recommend by the Trio include “From Here to Infirmary” and “Goddammit”. “From Here to Infirmary” is definitely more pop-punkish than the other two, it has some better production values, and was their first album to get any real airplay. It is still pretty funny in that dark humor kind of way and so definitely worth a listen to.

That’s all I got for today, and the funny thing is, I’m in a good mood, not bitter at all, go figure.

Share/Save/Bookmark

Mapping Oracle Forms to ADF 11g - An Overview

 If you are looking to migrate your Oracle Forms applications to Oracle ADF applications, you have probably wondered about how they would map. You probably did a google search and ended up at the Oracle ADF Equivalents of Common Oracle Forms Triggers page. This isn’t a bad reference, but it only talks about triggers and there is a lot more to a form than just the triggers.

The basic outline of the mappings we use is shown in the diagram here. We essentially use Task Flows to encapsulate the entire functionality of what used to be a Form. The Task Flow allows all functionality including complex business logic, navigation, included popups and dialogs, and even other Task Flows to be shown visually in the Task Flow Designer page in JDeveloper.

Since transactions can be nested, when one form calls another, that can be shown in the Task Flow diagram also. Task Flows are also nice to use in that they can be used to encapsulate transactions.

Another mapping we typically use is to map what were Windows in Forms to JSPX pages in the ADF application. We typically use the JSPX extension to denote that the page is an XML-compliant JSP page. The Items within the Window or Canvases are mapped to ADF Controls.

Blocks map relatively well to Views if they are Query-based blocks. The attributes in the block become attributes on the view that is associated with the Entity that relates to the table the original Block was based on.

The link above that I included talks about transaction related triggers but what about other triggers, like WHEN-VALIDATE-ITEM? Where do those triggers get mapped? In our experience, those types of triggers require some more thinking to map and cannot just be mapped blindly. While it is true that you could map all of those types of triggers to a Java method if you wanted to, since ADF includes the Groovy expression language you probably wouldn’t really want to. Simple validations (and even some complex ones) can be performed in Groovy and thus would probably be best as Groovy expressions. If you could move the validation that was done at the UI level in the Form to the Entity level in ADF you would be even better off. That way you wouldn’t need to repeat the same expressions in every page that modifies that entity.

As June and ODTUG approaches I will be posting more and more excerpts from my presentation (of which this is one).  They will include more detail on some of the ADF features and how those features may apply to migrating Oracle Forms apps to ADF as well as some more step by step how-to guides that go into some of the development details on creating different types of screens in ADF.

Share/Save/Bookmark

Knowing When To ResultSet.Close() and When to Close Your Mouth

Just a quick story from a recent conference we spoke at. At a lot of these conferences or User’s Group meetings there is a question and answer period in which attendees ask questions of all the speakers. The questions I have heard have generally been technical in nature and since most of the speakers are pretty technical, there is a lot of expertise on the “panel”.

At a recent conference, an attendee asked a straightforward Java question. He wanted to know why after sometime of running his Java application, which was a web application running WebLogic, his application would start getting errors from the database that there were too many cursors open.

This is a pretty common problem for beginning Java developers using JDBC and I remember one time about 10 years ago (there I go dating myself again), when I was first working with JDBC I had a DBA come running over to me complaining that I was using up 50 connections to her precious development database. This was my first week at the job and she was an intimidating person. It was then that I learned all about closing connections, statements, and result sets when using JDBC.

Anyway, somebody there on the panel started immediately with “I don’t mean to be rude, but you can’t expect us to answer a question like that without knowing more details about your situation, like what is the application trying to acheive, why is it using JDBC, why are you retrieving a REF_CURSOR…?” and on and on a bit.

I finally managed to get a word in and told the guy, “You should make sure that you are closing your ResultSets and even your Statements in the finally clause of a try/catch block.” This apparently didn’t satisfy the first guy who continued to go on for another 20 minutes about how the every search is now a pagination and it doesn’t make sense to get an unlimited set of results if you are only showing 10 on the screen and how you should really use a PL/SQL Collection to and a stored procedure to return the exact set of results you want, and blah, blah, blah.

I again managed to interupt enough to put in my two cents that if you are forgetting to close ResultSets in JDBC you probably don’t want to bother trying to return PL/SQL Collections yet.

I explained this to my wife, who isn’t technical by comparing it to someone asking a question about cooking, whenever I cook chicken in a frying pan (non-teflon!) it sticks to the pan, what am I doing wrong? to which the simple reply would be “add some oil to the pan first”. The guy I am describing would answer with an entire explanation of why you should bake your chicken instead and insist you can’t get a good answer unless he knew all the spices you were using and the dish you were trying to cook.

I thought it was kind of funny and it was really no surprise that the first guy’s talk was on what? You guessed it…”PL/SQL Collections.”

Share/Save/Bookmark

Speaking Engagements in March 2008

Ernst and I spoke at the Northeast Oracle User’s Group Training Day last Thursday.  We were really expecting more of a turnout, as it happened, there were about 75 attendees and about 10 attended our session.  They were expecting 200 attendees and blamed the weather on the poor turnout.  I suppose the weather was pretty bad in the morning, it was raining so hard that a few roads were actually shut down due to flooding.  However, this is New England we are talking about, it should be no less than a Nor ‘Easter to slow things down.

Tomorrow we speak at the New York Oracle User’s Group general meeting.  Hopefully the turnout there will be a little better.

Ernst needed some more technical “meat” in his presentation so I agreed to extract some of the technical overview in my presentation for ODTUG and present it as the second portion in his presentation.  It turned out to be a decent presentation with a nice overview of where Oracle Forms is headed and what customers options are combined with an overview of where ADF is now and why it is a good choice for customers looking to move their applications.

I will be doing a very similar presentation to the one I will be presenting at ODTUG in Georgia on the 24th of March for the Georgia Oracle User’s Group.  This one is actually a conference so it should be a little more lively than the other two.  Also, since Ernst isn’t presenting, I’m doing more of a straight technical talk to try it out for ODTUG in June.

If any of you are able to make the trip, I encourage you to check out the talks.  If you show up and let me know you heard about it on this blog then I’ll make sure you get a very cool Vgo Software t-shirt.

Share/Save/Bookmark

My Top 5 JDeveloper Tech Preview 3 Annoyances

Tech Preview 3 of JDeveloper was released around Christmas, which made a nice present for those of us concerned with such things, but as much as I hoped it would fix some basic issues, instead, it added some missing features that I didn’t really need yet and did not address some of the more, in my humble opinion, important issues.

Of course, some of this is perfectly understandable, but I hope the good developers and product team over at Oracle realize that there are a couple of basics that need to be addressed if JDeveloper is ever going to make it to the mainstream.  Here is a short list of some of the items I found in Jdeveloper that bug me.

1. Fix the in-editor code checking. Sometimes I swear this actually works, actually, I know it does sometimes, but other times it doesn’t pick up on basic errors (like duplicate method signatures in a class) until the compiler finds it. This is a basic of all great IDE’s and is one of the biggest issues I have with JDeveloper right now.

On the plus side, it has a somewhat decent editor checker for some of the declaritive properties and Groovy expressions which leads me to my second point.

2. The expression editor is cool and great idea, but at the moment, it doesn’t provide all of the functionality it should. For instance, not all the keywords available are in the editor and sometimes it marks things as invalid (though does not prevent you from using them) even when they are actually valid. Having everything that you could use in the current expression available to you in the editor would be a huge help, instead I find myself combing the web for “Tips and Tricks” articles to find those keywords I need.

3. Fix the property editor. As nice as it is to have the property editor so you don’t need to worry about the names of all those properties and edit the source code directly, it would be nicer if you could fill in a property and not need to click on something else (or remember to press enter)  in the property panel to get JDeveloper to recognize the change. While it becomes second-nature after a while (as does saving after virtually every change), it is really a problem that needs to be addressed.

4. CVS integration leaves a little to be desired. The synching with the server doesn’t seem to work right, and files that are found under the .adf folder and src folders are not added to the project, or if they are, aren’t updated or synced correctly. Other times, synchronization with the CVS server seems to be a little flakey, it doesn’t always catch all the changes and sometimes you need to restart JDeveloper to force it to. On the plus side, some of the merging works really well. And yes, I know, CVS is sooo 2005, but it’s what we happen to be using right now.

5. It may be a little ahead of it’s time. I say this because it apparently was developed with the idea that all developer have 3600X2100 screens to develop on. I unfortunately am limited to 1680×1050 when my laptop is docked and it just isn’t enough real estate for JDeveloper. Maybe in 5 years when my montior is double the size and I have an updated video card I could make use of all the panels that are displayed at once. What I may do in the intermin is hook up another monitor and see if detaching some of those panels and putting them on another screen helps at all, I assume it should but I wonder how well that will work.

As I mentioned, this is a Tech Preview of the product (Tech Preview 3)  so there is ample opportunity for them to fix some of these issues and I am sure a few of them will be addressed.  I just thought I’d throw them out there to vent a little and see what the rest of the community has to say.

Share/Save/Bookmark