Dive into Oracle ADF

Send me a mail
 Dive into Oracle ADF   Click to see the XML version of this web page.   (Updated: 2/3/2008; 9:14:38 PM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper IDE

Search blog with Google:
 

Search BC4J JavaDoc:
 

September 2004
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Aug   Oct

Get Firefox!

Wednesday, September 22, 2004

Tuesday the 21st was a chock-a-block full day for me here in Århus, Denmark, at the JAOO Conference. I started the day giving the keynote address to about 1000 conference attendees.  The topic was J2EE and Web Services: What's Next? I talked about Service Oriented Architectures, and helped attendees understand how the front-end and back-end of SOA-based systems could be built in a productive way on the J2EE platform. My demos included examples of doing drag and drop data binding in JDeveloper 10g using the ADF framework's support for JSR 227 for web services and Java-based business services, as well as a neat demo of the Oracle BPEL Process Manager that showed how BPEL can be used to orchestrate complex interactions with other web services (and human participants) in a business process.

The second talk of the day I gave was JavaServer Faces: Where are We and What's Next? This was a parallel track presentation, and it was going at the same time as local (Danish) hero Anders Hejlsberg of Microsoft -- father of Turbo Pascal, Delphi, C#, the .NET CLR, and the .NET framework -- talking about C# 2.0, as well as a talk by Rickard Oberg about Aspect Oriented Programming that I'm sure were both well attended as well. The room was packed, with what I'd estimate was about 350 Java developers, so I was super-pleased with the turnout. I gave an overview of the JSF technology and tried to give attendees an idea of what community support for the JSF standard already exists by demoing a number of existing JSF-aware tools, implementations, and components. I also showed off a sneak preview of the visual editing support for JSF coming in the next major release of Oracle JDeveloper 10g, the 10.1.3 release -- which will follow the 10.1.2 maintenance release coming in Fall 2005. The audience was quite impressed with the rich set of JSF components we provide in our Oracle ADF Faces components library for JSF developers.

I chatted with a reporter from Danish Computerworld about Oracle's BPEL implementation and strategy, and then later in the day participated in a J2EE Panel discussion with Martin Fowler, Rod Johnson, and Eberhard Wolff. We got a lot of interesting questions from the audience.

Today I gave a talk about Oracle ADF: Drag and Drop Databinding for J2EE Business Services, and then took a couple hours off to walk around Århus since I usually just fly in, speak, and fly out when I talk at events like this.

Readers who may have been disgusted by the whale steak I sampled last week in Norway, will be happy to know that I passed on some Zebra carpaccio that was on the menu at the nice restaurant my Oracle Denmark colleagues brought me to last night. We instead went for the restaurant's signature surprise sampler menu, served by a jovial waiter who was knowledgeable about all the food we sampled. I continued to prove my theory that New Zeland does not make a bad Savignon Blanc. The bottle of Gravitas we shared was quite nice. The only blemish in an otherwise perfect meal was the chain smoking businessman at the table next to us, who continued to surprise us all by holding a burning cigarette in one hand while eating with the other. Luckily, the windy Århus evening did it's best to clean the smoke smell out of our jackets, shirts, and hair on the walk home.


6:08:58 PM    



A user writes in to ask:

In my application I need to submit and commit together every time I do a New or Update. I did various tests, among which the "strange" attempt to substitute the Submit button directly with a Commit button. This means that for every New or Update, rather than clicking first on the Submit button, then on the Commit button, I can just click on the Commit button. I saw that with this method the record is effectively inserted or updated in the DB and this surprised me because I thought that the Commit button only did commit, and not insert plus a commit. Is it ok to just put a Commit without first doing a submit? What does the Commit event really do?
There is nothing special about the Commit button. It's just a button that gets named event_Commit by the ADF design time so that it causes the event named "Commit" to be fired when a form is submitted by pressing on that particular button. Recall from this section of the the ADF Data Binding Primer and ADF/Struts Overview that:
  When an event named YourEvent fires, then...
  1. If you have a public void onYourEvent(DataActionContext ctx) method in the data action class handling the request, it will be invoked to handle the event with custom code.
  2. If you have an action binding in the current binding container named YourEvent, it will be invoked.

    When used in combination with 1, your event-handler code needs to explicitly invoke the default action for the current event by using code like:

    if (ctx.getEventActionBinding() != null) ctx.getEventActionBinding().doIt();
  3. If you have a Struts forward named YourEvent, it will be used to determine the next page to forward control to.

    When used in combination with 1, if your event-handling code invokes ctx.setActionForward(), then your programmatically set forward takes precedence.

So, this means that when the Commit event is triggered by pressing the Commit button, it would:

  1. Fire the onCommit() method in your data action class if you had one.
  2. Invoke the action binding named Commit in your current binding container
  3. Use a page forward named Commit, if it finds one, to perform declarative page flow

Assuming that you did not have an onCommit() method and did not have a forward named Commit, then the net result is that only number (2) above would occur.

If you look in the UI Model tab in the structure window for your page, you'll see that the Data Control palette's drag and drop operation automatically added an action binding to your binding container named Commit when you dropped the Commit operation from the palette. So this explains why the commit occurs.

But, why does the modified row get updated or the new row get inserted as well?

The answer lies in understanding the Data Action lifecycle. This section of the ADF Binding Primer describes it. Specifically, it says:

The DataAction lifecycle handles:

  • Preparing the model layer for rendering
  • Updating the appropriate binding container control value bindings with values from a posted web form,
  • Engaging model-layer validation and batching up a maximal set of exceptions that are thrown
  • Reporting all exceptions as Struts ActionErrors
  • Invoking the appropriate control action bindings in the binding container when the appropriate buttons are pressed
  • Invoking a custom method on a data control based on declarative metadata.
  • Returning an ActionForward to decide where the flow of control should go next, on to a page for rendering or on to another action.

You see that the "updating the appropriate binding container control value bindings with values from the posted web form" phase in the lifecycle comes before the "Invoking the appropriate control action bindings in the binding container" phase. So in general, the model updates are applied before the event handling occurs. This explains why the submitted form values are applied to your new or existing row before the Commit event is handled.

The net result is that you get both model updates and Commit event-handling occurring which is what you want.

Two additional tips on this subject:

  1. When the Data Control palette creates a button in a JSP page, it creates it with an extra little EL expression inside the <input> tag to disable the button if there aren't yet any changes to commit in the transaction:

    <input type="submit" name="event_Commit" value="Commit" <c:out value="${bindings.Commit.enabledString}"/>/>

    If you are wanting to submit changes to an existing row and commit in the same step, then you probably want to remove the disabling expression to have a button that just looks like this:

    <input type="submit" name="event_Commit" value="Commit"/>

    this way the Commit button will always be enabled.
  2. If you are looking to perform a delete and commit in a single step, then this article contains some suggestions for how to do that.

4:23:46 PM    


© Copyright 2008 Steve Muench.