Thursday, 18 February 2010

March "Oracle Web Services" presentations extravaganza – Auckland NZOUG 15th/16th, Canberra ACTOUG 18th and Adelaide AUSOUG 19th

I'll be presenting in 3 different cities during March, presenting the same 2 presentations in both cities:
  • Back to basics: Simple database web services without the need for SOA

  • Oracle JDeveloper 11g JAX-WS Web Services: As easy as 1-2-3: XSD, WSDL, Generate!
These 2 presentations are ideal for Oracle database professionals, be it developers and DBAs in understanding how to create and consume web services from the Oracle database, as well as from Oracle's own JDeveloper IDE.

The dates:
  • NZOUG Conference - Auckland Mon/Tue 15th/16th March
  • ACTOUG Monthly Meeting - Canberra Thur 18th March
  • AUSOUG Monthly Meeting – Adelaide Fri 19th March
Complete presentation abstracts:

Back to basics: Simple database web services without the need for SOA

Oracle is heavily heading down the SOA line which can be intimidating to database programmers with no experience in the web service arena or running application servers, let alone SOA. This presentation will identify as a first step that database programmers can make use of database packages like utl_http, utl_dbws and 11g's Native Web Services for consuming and publishing web services without adopting SOA straight off the ranks.

Oracle JDeveloper 11g JAX-WS Web Services: As easy as 1-2-3: XSD, WSDL, Generate!

Web services used to be hard. Creating XML schemas, long-winded Web Services Description Language (WSDL) code, and back-end Java code took much effort. Today Oracle JDeveloper 11g enables developers to visually design both the schemas and WSDL code by drag and drop and generate Web services based on both of these with the latest Java EE JAX-WS/JAXB Web service standards with just a few clicks. Finally programmers can get back to thinking about the programming problem they need to solve without wasting time setting up the Web service artefacts, which can be tedious, error-prone, and very repetitive. Learn more in this session.

I look forward to seeing you there.

Wednesday, 17 February 2010

JDev 11gPS1 – text editor enhancements

I note in the last 11gPS1 release of JDev (well, at least I didn't see it in any earlier releases) that the text editor has a few additional facilities available under the Source menu:


Of particular note there are now entries to Trim Trailing Whitespace, and Convert Leading Tabs to Spaces, which for me have always been important text editor feature, as both of them make editing source code easier beyond their application. Some of these features such as the Macro playback options have been available for a longtime in JDev as revealed by looking through the Shortcut Keys options under Tools -> Preferences. However the point is they now get a menu option!

As a side note, some of the Source menu features can be applied automatically when saving a file. This option is accessible via the Tools -> Preferences -> Code Editor -> Save Actions options:


The Save Actions facility was available in earlier releases of JDev, well, at least 11.1.1.1.0 where I could test it on my local machine.

Wednesday, 10 February 2010

ADF BC Groovy – showing old values along with new part II – via ViewRowImpl

A while back I posted about using Groovy within our ADF BC EOs to expose the new and old values of a particular attribute. This method described in that post works fine if you've access to the EOs in the same project. However in our current project EOs are segmented in another application workspace project for reuse and ADF Library JARed into our existing "master" ADF BC workspace project. The external EOs are intended to be shared by multiple other sub-systems, and it really didn't seem ideal to include additional transient attributes on all the attributes in the shared EOs just in case some other application needs them, mostly they wont want this specific requirement.

This lead to the requirement to include the same functionality, namely transient attributes based on a Groovy expression to return the old value of the attributes, from our project's VOs instead. In other words, if a VO needs them, it includes 'em.

We immediately hit a problem on implementing this requirement. The EntityImpl.getPostedAttribute(index) method is a protected method, and there is no equivalent ViewRowImpl method. Arguably it should be provided at the ViewRowImpl level, and a search of the JDev OTN forums shows it's an old issue and I guess not likely to change anytime soon.

Without an immediate change to the ADF BC framework, we needed to find another solution. What we came up with:

(As per the original post we'll assume we're looking at the Employees EO and Position attribute)

1) By default extend the ADF Business Components Framework as per section 37.1 Globally Extending ADF Business Components Functionality of the Fusion Guide.

2) In the extended EntityImpl class, say common.model.CommonEntityImpl, create a public exposed version of the getPostedAttribute method
public Object getPostedAttribute(int index) {
return super.getPostedAttribute(index);
}

3) For the specific VO interested in showing the old values of an attribute, create the associated ViewRowImpl (say EmployeesViewRowImpl). Ensure in the generated class an accessor method to access the underlying EntityImpl has been created, ie:
public EntityImpl getEmployees() {
return (EntityImpl)getEntity(0);
}

4) In the local project's VO transient attributes to show the old values base it on the following Groovy expression:

adf.object.getEmployees().getPostedAttribute(model.entities.EmployeesImpl.POSITION)

What it does:

a) adf.object.getEmployees() calls the EmployeesViewRowImpl.getEmployees() method we checked existed in step 3, to retrieve the associated EntityImpl for the current ViewRowImpl

Note if you haven't undertaken step 3 to generate the associated ViewRowImpl, alternatively you could just call getEntity(0) instead in your Groovy expression. However I'd be cautious on doing this as you're relying on future upgrades of the framework not changing what's at position zero.

b) .getPostedAttribute() calls the now publically exposed getPostedAttribute method we created in the common.model.CommonEntityImpl that gives us the ability to get at old attribute values in the EO

c) The parameter model.entities.EmployeesImpl.POSITION grabs the index position of the Surname field in the EO. Note we need to use the EntityImpl field position rather than the ViewRowImpl field positions, as the order of the fields can be different.


Of interest to this post, an old discussion on the ADF Enterprise Methodology Group, was do most projects extend the ADF framework as per section 37.1 Globally Extending ADF Business Components Functionality? As can be seen from this specific blog post this shows another reason to include the extended classes from day 1 of any ADF development.


Final caveat: Please note this post is mostly for self documentation purposes, posted here so others can make use of it, but is not guaranteed to work; honestly I haven't tested this thoroughly nor has it been placed in a production environment yet. As such be careful to check it works for you, your mileage may vary. If you find any problems it would be appreciated if you could post your findings here to assist other readers.

Friday, 5 February 2010

ADF Faces RC: af:document uncommittedDataWarning property

Thanks to some assistance from Richard Wright from Oracle Corp on the OTN forums a week or so ago, I learnt about the uncommittedDataWarning property in the af:document tag, which I'd like to describe in this post.

This property is useful in the following scenario. Imagine you have a page as follows:


As you can see the page allows the user to change values of the current employee, and behind the scenes this is based on the usual ADFm bindings. In turn note the 3 buttons and their labels. For this screen there is a strict requirement for the developer to either Commit their changes or Undo them, before navigating back to the Home page.

Before the introduction of the uncommittedDataWarning property, the user could select the Go Home button and bypass this requirement. A workaround would be to set the Go Home button's disabled property such that the user couldn't navigate through the button if there were changes to be saved. However this is easily defeated by the user hitting the browser's back button, with the ensuing "JBO-35007: Row currency has changed since the user interface was rendered" mess that confuses users and developers no end.

With the introduction of the uncommitedDataWarning property for the af:document tag, and setting it to "on", if the user selects either the Go Home button (assuming we haven't disabled it) or the browser's back button without committing or undoing their work, they'll see the following browser error:


The dialog gives the user the option to Cancel, which leaves them on the current page, or Ok, which allows them to complete their action.

This is definitely an interesting feature, especially with its browser back button support.

One thing to note is that it only works for data that goes through the ADF binding layer. As such if you've JSF components based on a bean that isn't exposed to the ADF layer through a data control, it won't capture the data change. Thus this is another reason to ensure you don't hack code into the JSF layer, but expose it all through ADF Business Components or the other supported business service layer in ADF.

Also at this time the feature has a couple of limitations worth mentioning:

1) If the dialog displays and the user selects ok, the dialog will continue to display on each further page navigation until the user either commits or rolls back their changes. I can imagine this will become confusing or frustrating for some users, especially if you don't provide commit/rollback buttons on other pages.

2) As noted in this OTN post, I note that it is a warning mechanism and not an error mechanism (or at least, it doesn't have an option to enforce no navigation). It would seem ideal, especially with its back button functionality, to display an error only, leaving the user on the same page and forcing them to do a commit. Obviously this wouldn't be ideal in all cases, but certainly in some. I've raised ER 9299581 with Oracle Support for this.

3) As Richard Wright points out in the same post, "for a similar use case there has been a request to allow the user to continue with either a commit or rollback from the dialog. It would be analogous to the "Save" dialog received when exiting a native app (e.g., Word, Excel, JDev)." Hopefully we'll see these ERs in a future release.

I'm not overly sure when this property became available but I'm guessing the original JDev 11g release. It's definitely available in 11gR1 which this post was written against.