Monday, January 23, 2012

Create a calendar item returning week numbers

When you use the built-in jQuery UI datepicker in your APEX page, you choose from a number of different format masks...but something with "week" is not one of them. And guess what I needed for recent project...
But, the good news is, you can (rather easy) use the jQuery framework to tweak the result that's returned from the datepicker.
Just create a Dynamic Action that fires on load of the page, and add these line of Javascript:
//Show the week number as the first column
$( ".datepicker" ).datepicker( "option", "showWeek", true );
//Set Monday as the first day of the week
$( ".datepicker" ).datepicker( "option", "firstDay", 1 );
//Return yyyy-ww instead of the actual date
$(".datepicker").datepicker("option", "onSelect", 
      function(value, date) 
      { var week=$.datepicker.iso8601Week ( 
              new Date(date.selectedYear,
That's it. Of course you have to replace the jQuery selector - $(".datepicker") - with the one that matches your selection.
You can also substitute the function that generates the week number with your own one. And, yes, you could turn this into a plug-in if you like... (maybe I will when I've got the time, but no guarantee).

Tuesday, January 10, 2012

Wouldn't you like to talk to your APEX app?

Of course you are familiar with Martin Giffy D'Souza's blog (if you're not, check it out - it's really worthwhile). But wouldn't it be nice to not only talk about APEX, but also to APEX?
The only thing you need is a recent version of Chrome (11 or up) and a microphone. And then...just by entering "x-webkit-speech" to the HTML Form Element Attributes of your input item, you have speech-enabled your application!

All "speech enabled" items will get a little mic at the end. When you click on it, you can say what you like. Oh yeah..and it works for number and date fields as well!
One remark : Whatever you enter will go through Google's voice recognition ... so Big Brother is listening in on you!