Thursday, March 31, 2011

Book Released: Oracle Application Express 4.0 with Ext JS

I'm very happy to announce that my book Oracle Application Express 4.0 with Ext JS is now officially published.

A printed copy turned up in the mail recently, and I'm very pleased with the final result.


 The table of contents for the book as well as a sample chapter is available on the Packt website.



Sue Harper blogged about the three phases of book writing:

  • before the book - Seems like a good idea
  • during the book - Not a good idea, will this ever end? Who's idea was this anyway?
  • after the book - That was easy ... what's next?

After spending most evenings and weekends writing until midnight for the last 15 months, I've definitely done the first two phases, but haven't quite reached the last phase yet.

Still to do
The code bundle available to download on the Packt website includes code from each of the chapters.
I will be updating it in the next couple of weeks to:

  • include the Ext JS library, so the stand-alone examples work when the bundle is unzipped
  • add the APEX TEMPLATE application, CSS, JavaScript and image files used in the book
  • include a few extras that didn't make it into the book.
I'll write another blog post when the updated code bundle is available.

Then after that my demo site definitely needs an overhaul, it's looking sadly neglected...

Thursday, March 10, 2011

Bookmarklets to extend APEX 4.0

APEX allows you to add help text for your pages at a page level, and also an item level.
Your only given a plain textarea to add your text, as you can see in the following screenshot.
Hint APEX team: can we change this in the next version?

One way to replace the textarea with the APEX Rich Text Editor is to use a Bookmarklet, which allows you to embed JavaScript code in a browser bookmark.
Then simply click the bookmarklet to convert the textarea to a Rich Text Editor when needed:


Simply drag the following links onto your browser bar to save the bookmarklets:
The source code for the Page Level Help bookmarklet is:
javascript: (function(){
    function getScript(url, success){
        var script = document.createElement('script');
        script.src = url;
        var head = document.getElementsByTagName('head')[0];
        var done = false;
        /* Attach handlers for all browsers*/
        script.onload = script.onreadystatechange = function(){
            if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
                done = true;
                success();
            }
        };
        head.appendChild(script);
    }
    /* Code to execute after script loaded */
    function run(){
        apex.widget.ckeditor3("#F4000_P4301_HELP_TEXT", {
            "language": "en",
            "toolbar": "Basic",
            "toolbarStartupExpanded": true,
            "skin": "kama"
        });
    }
    /* Main */
    if (!window.CKEDITOR) {
        getScript('/i/libraries/ckeditor/3.2/ckeditor.js', function(){
            run();
        });
    }
    else {
        run();
    }
})();

All we are doing is adding the ckeditor.js file when it's not present, and then converting the specified page item to use the basic CKEditor.
For the advanced version replace "toolbar": "Basic" with "toolbar" : "Full".

You may need to adjust the item reference if your not using Application Express 4.0.2.00.07, or a translated version.

Friday, March 4, 2011

APEX_PUBLIC_USER password expires on 11g

Just read Scott Wesley's post on APEX Listener issues which was being caused by Oracle 11g automatically expiring passwords.

The cleanest solution is to use an unlimited password lifetime profile, and assign to APEX_PUBLIC_USER.

This is done simply by:

CREATE PROFILE UNLIMITED_PASSWORD_LIFETIME LIMIT
  SESSIONS_PER_USER DEFAULT
  CPU_PER_SESSION DEFAULT
  CPU_PER_CALL DEFAULT
  CONNECT_TIME DEFAULT
  IDLE_TIME DEFAULT
  LOGICAL_READS_PER_SESSION DEFAULT
  LOGICAL_READS_PER_CALL DEFAULT
  COMPOSITE_LIMIT DEFAULT
  PRIVATE_SGA DEFAULT
  FAILED_LOGIN_ATTEMPTS DEFAULT
  PASSWORD_LIFE_TIME UNLIMITED    /** this sets unlimited lifetime */
  PASSWORD_REUSE_TIME DEFAULT
  PASSWORD_REUSE_MAX DEFAULT
  PASSWORD_LOCK_TIME DEFAULT
  PASSWORD_GRACE_TIME DEFAULT
  PASSWORD_VERIFY_FUNCTION DEFAULT;


ALTER USER APEX_PUBLIC_USER
 PROFILE UNLIMITED_PASSWORD_LIFETIME
 ACCOUNT LOCK;