Tuesday 22 December 2009

Apex 4.0 for Forms Developers

It was less than a week ago I woke up to a flurry in the Apex folder of my RSS feed and I knew something Apex related had been announced!

After reading Dimitri's comments regarding Apex 4.0's Tree View vs Component View, I had to learn more about this new view as it immediately made me think of all the Forms programmers out there learning Apex.

In addition to Oracle's Apex page dedicated to Forms developers, their Oracle Development Tools Statement of Direction states that instead of creating migration tools, they wish to create environments that expose similar concepts as Forms and Reports, giving to Forms and Reports developers the opportunity to become productive in a new, but familiar environment.

So as soon as I saw Apex 4.0's tree view, it made me think of the Oracle Forms object navigator.

Compared with the Forms object navigator, today's technology provides the Apex team with the ability to create a more dynamic environment. The browser environment, however, does also bring it's drawbacks.
Expanding and collapsing in Forms, while minor, did create time saving opportunities.

As Dimitri noted, the tree view does also limit the information you can see at once, such as conditions. I can foresee having to locate these via tool-tips may become frustrating.
On the plus side, the quick drag and drop feature will be handy, and the right mouse click is context sensitive

 I do agree with Dimitri in his comment that the tree view does provide an insight to the overall page process. This can assist Forms developers and those new to the Apex environment, but let's not forget the Page Events view.

Previous to Apex 4.0, this was one click away - however now it's three clicks and two pages away.
Utilities -> Additional Utilities -> Page Events

This Page Utilities option offers some new layouts that may turn out to be useful, plus a location to store links for some existing features.

The grid edit of pages is a nice way to modify those attributes, and navigate to the relevant pages - but does take time to navigate to. The page attributes also provides a potentially useful summary detailing counts of various page components.

There are also subtle changes around the place, one I do like is the runtime Developer Toolbar is now "frozen" to screen like a semi-transparent frame.

After a quick browse through the Application Migrations section, there are no obvious changes to the Forms to Apex conversion utility - including fixing some issues I uncovered while writing my presentation.

In an overall perspective, I think more screen real estate is unnecessarily used - particularly by the main application page. For those of us using laptops, screen height can be an issue. That being said, I do look forward to seeing how useful the various new dashboards can be.

As for the tree view, I'm undecided where I may spend most of my time. I think while it does illustrate the page processing very well, those familiar with Apex intricacies may stick with the existing screen showing more information is shown without interaction, and where double clicking is not necessary.

This is all without mentioning the extra coding grunt being provided out of the box. Keep a close eye on the Apex blogs for more information on these.

Friday 18 December 2009

11g Documentation trick

One handy tip I learned at the conference wasn't at one of the seminars, but whilst having an amber ale with my esteemed colleague Connor McDonald.

Neither of us seem to be a fan of the expand/collapse feature in Oracle, nor the navigation bar. However it was Connor that took the time to find a simple edit to restore the look and feel to pre 11g levels.

Where your local version of the documentation is stored, simply rename this file

And instead of the documentation looking like this on entry, requiring more clicks to do anything of use:

It will look like this, all ready to search for your keyword of interest:

The main page will retain it's little search area, although if you use that, it will search online - so you might as well utilise something a little more powerful and handy like Ubiquity.

I don't know what the folks at Oracle Documentation HQ think of this, but at least it's not tinkering unlawfully with the database.

Wednesday 16 December 2009

JQuery Datepicker

Recent suggestions indicate that JQuery will be included as one of many new features in Apex 4.0, so why not start having a play with it now?

Take the example of the JQuery datepicker. The original date picker that comes with Apex reminds me of web applications from yesteryear, and it's welcoming to see a feature that feels integrated with the web page.

The documentation for these features are thorough and at first glance can seem a little overwhelming, so why not illustrate an example specifically for Apex? There are a few sets of instructions out there in the Apex blogging world, but this is what I found useful when I wanted to experiment with the features, plus a few thoughts of my own.

1) Download the bundle of components from jqueryui.com/download
Here you can select the theme your interested in - perhaps match it up with the theme you're using for your Apex application. You can also select what components are going to be included. If you want to keep your application light, deselect those you do not need, or you can prepare multiple copies and attached the relevant ones to the relevant pages in your application - you have a few options for this I'll mention shortly.

The download will also include an index.html to the development-bundle folder, allowing you to demonstrate with a local copy of the scripts.

2) Make the files visible to your workspace.
The following files are a must for the components to work
jquery-1.3.2.min.js -- this represents the functionality core to jquery, all components will need this script
jquery-ui-1.7.2.custom.min.js -- this will include any components you've checked in the build stage on the JQuery website
jquery-ui-1.7.2.custom.css -- this of course represents the theme you selected. Without it things will look a little strange.

If you're working with the embedded PL/SQL gateway, you will need to upload the files as Static Files or Images in Shared Components. By the looks of the CSS, JQuery doesn't seem to be built to easily adapt to this Apex setup, so you may have difficulties incorporating the images. If you wish to use JQuery, I'd suggest using Apache.

If you're working with Apache, they will need to reside somewhere in your /i/ folder. Note the images will need to be in a folder called ./images, relative to the location of the CSS file.
ie -

3) Include the scripts as part of your page
When referring to file locations, Apache will refer to #IMAGE_PREFIX#, and the embedded gateway to #WORKSPACE_IMAGES#
Further to this, it would be better practice to store your file location in a computed application that will return the relevant file location depending on your environment, for instance:
<script src="&F_FILE_LOCATION.jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="&F_FILE_LOCATION.jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="&F_FILE_LOCATION.jquery-ui-1.7.2.custom.css" />
Some people choose to place this within the template, others like to include it in page zero where it may be conditionally included in various pages. This condition could be to include the JQuery scripts only on pages that utilise it. If you want to be really specific, you can include different scripts representing different components. You don't need to use the custom script you generated, you could refer to the specific .js files as required - check out the documentation for further tips.

4) Invoke the JQuery code
Within the page that will utilise the JQuery feature, you need to invoke the relevant function during page load. Again there are a few options here:
a) Include the following script in the source of the page
<script type="text/javascript">
    showOn: "both",
    buttonImage: "#IMAGE_PREFIX#asfdcldr.gif",
    buttonImageOnly: true,
    showOn: 'button',
    dateFormat: 'dd-m-yy'

Edit - modified dateFormat to match documentation.

And apply to the item's HTML Form Element Attributes property:

b) Include the same code, but in the highlighted line 10, add referenced to your selected items:

c) Or apply the date picker to all items in the application
<script type="text/javascript">
  // Convert all Datepickers to a jQuery DatePicker
  // Remove the native Oracle Apex DatePicker and add JQuery one
    { dateFormat : 'dd-mon-yyyy'
    , showOn : 'button'
    , buttonImage: "#IMAGE_PREFIX#asfdcldr.gif"
    , buttonImageOnly : true

And voila! You'll have applied a JQuery component to your application. Why not start playing with other widgets?

Stay tuned for the implementation process come Apex 4.0

Monday 14 December 2009

How Developers should ask for help

Back in October ZDNet Australia posted a brief video interview of Tom Kyte describing How developers should ask for help (linked by Eddie Awad). I thought I'd mention it now since I was talking to a few colleagues at the recent AUSOUG Conference and they don't recall seeing the video.

When I was first learning Oracle, I spent about 20 minutes every morning reading entries on AskTom and learned a lot! You also get a feel for someone's personality when you continuously read responses to questions posted by all varieties of people. Frankly, Tom's a witty fellow. I especially like his oft used analogy of comparing apples to toaster ovens.

I also empathise with some of his pain in responding to questions that simply don't provide enough information. I must say I particularly agree with Dan Wilson's reply in the comments section. Regardless of the forum to which you may be posting a question, it's so important to provide a context, frame of reference, ins and outs etc.

Put yourself in Tom's shoes - what information would you like to receive from someone asking you a question about a technological problem? Do you want to hear "Why doesn't this query work?" or would you like to be provided with a really simple test case that provides you the ability to tinker straight away?

I also liked Tom's explanation of why he doesn't respond with RTFM. Not only is it important for everyone to learn by doing, it's also important for people to learn how to effectively find the correct documentation themselves - which should be the first step to nutting out a problem before you even consider approaching anyone. I'm passionate about documentation, and technical queries on Oracle functionality spurred me into writing my presentation on documentation usage.

Another analogy I find is when my eldest child tries to tell me about something in a book he's reading. Unless he puts it in context for me, I'm not really going to understand why it's funny. Or perhaps when I ask my father how to do some handy work around the house. I might ask him specifically how to do something, but if I don't even give him the bigger picture, he may not know to explain the even easier solution using different tools I wasn't even aware of.

This concept applies true to so many fields and situations.

Friday 11 December 2009

Interesting topics while I was gone

Not surprisingly, the world still ticks - even when I'm on holidays.

I've finally caught up with my RSS feeds - the work related ones anyway - and I've compiled a brief list of those that caught my eye in particular. When trying to catch up on three weeks of feeds, the best reads tend to stand out.

Comparing Oracle & MySQL - this may become more relevant as time goes on, and will certainly be useful every time my MySQL friend asks me Oracle questions.
Oracle XE 11g - while I'm not waiting for it, that would be a useful release, particularly for those who want to tinker and learn from home.
asktom.oracle.com/tkyte - I spotted the loss not long after Tom jumped domains, so it's good to see all his reference scripts made available again.
Multibyte characters - I encountered this issue recently, but not because I was coding for another language. I was importing data files that contained characters that I wasn't expecting, so I had to consider width as Alex described even though I was substringing a particular length.
Unwrapping PL/SQL - It's amazing how many people are curious about this.
Apex & Web 2.0 - There are some great demo applications linked through here.

And as I write this my replacement laptop power adapter arrived - let's hope it works. No more excuses for me!

Apex Application Alterations

Here is a tidbit I noticed that may be useful to someone.

Sometimes there comes a need to compare two applications to determine differences. Typically, this would be comparing an older version of the same application to see what has been changed (and try to determine why!)

Doing this via a text comparison of the export is tough. A simple compare of text files in TextPad gave me 5000 lines of differences for a copy of an application where I made one change! This would of course be due to the differences in IDs for all the objects. Perhaps an expert in text comparison tools may suggest an alternative there.

The Application Express builder provides a comparison tool for you. Once you have one of the applications selected, click on the Application Reports link in the Task List.

One set of application reports is "Cross Application"

There are two comparison reports, as opposed to the attribute listings:

Now this is an output of differences between my two applications, one was a copy where I made an attribute change of an item in a form.

The Show Details checkbox option does little to illustrate the difference Apex found, but the report can be a good starting point to debugging and locating a problem you may have.

In this case the Application Attribute difference is obvious - the application alias would have changed.
Page 7 relates to my change, so it seems to be highlighting some difference in the page itself, in addition to the item I modified. If the algorithm is using some form of checksum to make the comparison, this is not exceptional.
I didn't look into the page 35, where there is a blob displayed, nor the page templates.

If this is a task you may perform semi-regularly, they may be anomalies/expected behaviour you come to expect from the comparison and learn what is safer to ignore.