Monday, 3 September 2007

Developer productivity gains with 'Bookmarklets'

Introduction...
The ability to manipulate web content with Javascript on the fly is becoming more and more widespread, with tools such as Firefox's Greasemonkey, IE's Trixie and a whole host of other browser add-ons providing the ability to apply scripts to web pages. Bookmarklets are probably one of the simplest and easiest ways to achieve this, storing Javascript code in the URL of a bookmark or favorite. I have built a few which I find helpful in automating some of the more mundane tasks whilst developing with APEX.


How...
All you need to do is drag the following links onto your bookmarks / favorites toolbar in your browser. They are all compatible with Firefox and Internet Explorer.
  • Bulk Edit - Repad sequence numbers - Sequence numbers by default are padded by 10, but as the development process ensues, items get moved, processes get added and sequence numbers inevitably get scrunched up. This bookmarklet repads sequence numbers by 10 when in bulk edit pages where the 1st column is the sequence number, such as bulk editing page items, computations or validations.

  • General - Enlarge textareas - Enlarges small textareas for easier editing, useful for 'Region Definition > Source' or 'Page Process > Source'.

  • Report Attributes - Alignment LEFT - Sets both 'Column Alignment' and 'Heading Alignment' to 'LEFT' whilst on the 'Report Attributes' page.

  • Report Attributes - Sort All - Checks all the 'Sort' checkboxes whilst on the 'Report Attributes' page.

Once this is done, you can just click the bookmark / favorite when on the appropriate page and the Javascript will be applied.


Conclusion...
In my opinion bookmarklets are fantastic for implementing these type of simple extensions, the main reasons are:
  • Portability(1) - All my bookmarklets will work in Firefox and Internet Explorer.

  • Portability(2) - And this is important, using a Firefox add-on such as Foxmarks which synchronizes bookmarks between different instances of Firefox (home and work), your bookmarklets will be available to you on any browser you have synchronized.

  • Simplicity - Minimal learning curve for deployment, assuming a basic understanding of Javascript and bookmarks.

  • Categorisation - Easy to organise your bookmarklets into folders and subfolders, just as you would with your regular bookmarks.

  • Ease of use - I have my bookmarklets available on my bookmarks toolbar, ready for quick deployment.

As APEX developers, we live in a world of 'browser-based development', rather than a traditionally rich IDE such as JDeveloper and Eclipse. The standard browser was not designed to be used as a development tool and thus anything we can do to help increase development productivity, such as write custom bookmarklets or use the essential Firebug can really help. So have a go and write your own, here are some general guidelines including a very useful bookmarklet builder. During development, I find a 'could I automate this?' attitude helps in identifying bookmarklet opportunities.

Let me know if you have any more useful productivity increasing bookmarklets to share and I'll add them to this post.

Anthony.


Update - Another way...
Following the advise of Patrick and Dimitri, I've taken a look at the APEX Builder Plugin and it really is awesome, congratulations Patrick!

It is compatible with both Firefox (with Greasemonkey) and IE (with IE7Pro), and it's fantastic. Whilst bookmarklets are great for a quick fix, if you want to get serious about building your own productivity customisations then I strongly advise you to invest a little time looking at this plugin.

It does not change the APEX base install in any way and just requires the developer to have one of the above add-ons installed in their browser and the plugin scripts available to the workspace, either on the server or stored in the database as static files. Within a couple of hours I had it installed, had a good look around and was building my own extensions.

One of the features of the plugin is the creation of a custom 'Set' select list at the top of any page in the Application Builder. This comes with some useful pre-rolled 'Setters', and also and importantly allows the developer to easily define their own 'Set' options for all or specific pages. This not only makes work more efficient for the developer, it can also be leveraged for enforcing standards across a team developing in APEX.

I was able to recreate the functionality from my bookmarklet, 'Bulk Edit - Repad sequence numbers' on all the bulk-edit pages accessible via the 'Page Definition' page, with the following code:
// Page Items

ApexBuilderPlugin.addSetOperation
( "General"
);
ApexBuilderPlugin.addSetOperation
( "Repad sequence numbers"
, { "f01": function(pField, pRow)
{
return pRow + '0';
}
}
);

For further information on how to do this, please refer to the How to Install guide.

As well as providing the ability to define your own 'set' operations, it also provides the ability to map keyboard shortcuts to common functions, such as F10 for 'Apply Changes' or F8 for 'Run Page' and a much neater solution to the enlarge textarea problem.

Great work Patrick!!


Another Update...
I am now delighted to announce that my 'Repad Sequence Number' customisation will be included in the next official distribution of the plugin. Thanks to Patrick for giving me a mention.


Further Information...
Bookmarklet homepage
General Guidelines
Bookmarklet Builder
Web Development Bookmarklets
Oracle bookmarklets by Eddie Awad for searching documentation
APEX Builder Plugin

4 comments:

Dimitri Gielis said...

Hi Anthony,

Nice article and very true.
I'm using Greasemonkey with the Apex Builder Plugin of Patrick.

Dimitri

Patrick Wolf said...

Hi Anthony,

enhancing the Oracle APEX IDE is really powerful. I started an open source project for that some time ago. It covers a lot of the features you have written with your bookmarklets. It's an Gracemonkey/IE7Pro script which builds a plugin infrastructure to extend it with your own commands. Have a look at the Oracle APEX IDE Plugin.

Greetings
Patrick

Anthony Rayner said...

Dimitri / Patrick,

Thanks for the info and pointing me towards the APEX Builder Plugin. I have updated my post with a new section on the plugin, detailing recreation of my repadding sequence number bookmarklet within the plugin infrastructure.

Always learning!!
Anthony.

Craig said...

Anthony,

I've gathered together what I thought were the best general purpose bookmarklets for web developers and packaged them into a zip file called 'Sherlock'. If anyone is interested, they can read more about it and download the file at my site.

Craig