Friday, 4 February 2011

Is Apex heading in the right direction?

Ever since reading the Oracle Application Express Statement of Direction for 4.1, I've had it in mind to share some thoughts on this forum. So why not now when the water's settled, it's a new year after all and apparently we can look forward to 4.1 goodness in 2011.
  1. Development for Mobile Applications - any product, software, company, fish in the ocean with a vision of the future should be considering mobile applications. The word "applications" can have multiple contexts here, but I must say even for websites - it really grinds my gears when I encounter what I'm sure is a new website that doesn't appear nicely on my mobile phone browser. Good on Oracle for bearing this in mind.
  2. Charting - "without using Flash", obviously the iPhone is being considered here, but considering the CPU drain with Flash I think it's great that other charting options are being developed.
  3. Error Handling - I'm forever updating the (ugly!) Error Page Template with some sexy scripting here, so I'm glad that the Apex team are starting to tidy some of the looser ends of the product.
  4. Interactive Reporting - Not so sure about multiple reports per page, unless perhaps they are little ones on a very dynamic page; but supporting newer database features like pivot queries is great to see.
  5. Tabular forms - Multiple on one page? I avoid them like the plague myself, but more functionality with validation would be good - wasn't that impressed with the 4.0 improvements.
  6. Mater-Detail-Detail - makes sense.
  7. Dynamic Actions - never has a declarative feature offered so much potential and provided flexible options, I'm glad this feature is being developed further.
  8. Plug-Ins - The community has really embraced plug-ins, you'd be mad not to extend it.
  9. Use of ROWID - this has been on my wishlist for a while, it irks me this facility wasn't in a much earlier release.
  10. Modal Dialogue - I can only imagine this is a JQuery dialogue, something I advocate and have used a number of times to help ensure the end-user takes notice of pop-up messages, instead of blindly clicking.
  11. Websheets - do people really use this?! Please tell me the initial Apex4 release wasn't due to dusting off websheets...
  12. Data Upload - if this is what I think it is, I can see many applications for it and I think it will help developers the world over from reinventing another wheel. Perhaps an adjustment of the Data Load facility in Apex utilities?
  13. Accessibility - I'm finding more clients ask that this is considered in the requirements, good on you, Oracle.
  14. Numerous functional and performance improvements - I'm sure in this random bucket of goodies there will be the odd pearl. I remember re-writing our Oracle Apex training application from 3.x to 4.0, and it really was the little things that made me happy - unnamed improvements that made my task easier.
As for wishlist features, I'm the sort of bloke that grumbles at Apex every now and then, but do you think I can collate my whims on demand? Hardly...
  • Column reordering - one of the most frustrating but regular tasks in development, aiming for that little arrow to re-order fields. Perhaps a drag and drop mechanism?
  • Handling CSVs - depending on what that data upload improvement entails, I think it would be great to offer a black box that facilitates uploading a CSV file into an Apex collection
  • Validation that communicates - it would be wonderful to construct validation dependencies, enough said.
  • ROWID - I'll mention it down here too, handing DML by ROWID in lieu of primary keys is overdue.
And to top it all off, if Apex 4.1 is shipped with Oracle 11g XE, that would be super.

So is Oracle Apex heading in the right direction? You bet. All these focuses show that the Oracle team really are listening to the heartbeat of the development community - and of the web world at large, in my humble opinion anyway.

Scott

Thursday, 3 February 2011

APEX Object Synonyms

It's been almost a month since my last post - it's been January and I'm going to leave it at that.

I thought I'd continue 2011 with a little snippet I wrote to save some of my frustrations.

Occasionally I find myself reading the package spec for an Oracle Apex package, and I'd like to know the synonym name I can refer to it with - or I'm aware of a synonym name and I'd like to pull up the package specification for a look-see.

Either way, I always find myself trying to remember what to replace with what, seeing now it's usually just WWV_FLOW <-> APEX, but sometimes it's APEX <-> HTMLDB, and sometimes it's something else...

So I wrote a little query to help myself do the mapping between synonym name and package name, maybe you'll take it on board:
SELECT owner, synonym_name, table_name
FROM   dba_synonyms
WHERE  synonym_name LIKE 'APEX/_%' ESCAPE '/'
AND    owner LIKE 'APEX/_%' ESCAPE '/'
ORDER BY synonym_name
/

OWNER        SYNONYM_NAME                   TABLE_NAME
------------ ------------------------------ ------------------------------
APEX_030200  APEX_ACTIVITY_LOG              WWV_FLOW_USER_ACTIVITY_LOG
APEX_030200  APEX_APPLICATION               WWV_FLOW
APEX_030200  APEX_APPLICATION_FILES         WWV_FLOW_FILES
APEX_030200  APEX_APPLICATION_GLOBAL        WWV_FLOW_GLOBAL
APEX_030200  APEX_COLLECTION                WWV_FLOW_COLLECTION
APEX_030200  APEX_COLLECTIONS               WWV_FLOW_COLLECTIONS
APEX_030200  APEX_CUSTOM_AUTH               HTMLDB_CUSTOM_AUTH
APEX_030200  APEX_INSTANCE_ADMIN            WWV_FLOW_INSTANCE_ADMIN
APEX_030200  APEX_ITEM                      HTMLDB_ITEM
APEX_030200  APEX_LANG                      HTMLDB_LANG
APEX_030200  APEX_LDAP                      WWV_FLOW_LDAP
APEX_030200  APEX_LOGIN                     HTMLDB_LOGIN
APEX_030200  APEX_MAIL                      WWV_FLOW_MAIL
APEX_030200  APEX_MAIL_ATTACHMENTS          WWV_FLOW_USER_MAIL_ATTACHMENTS
APEX_030200  APEX_MAIL_LOG                  WWV_FLOW_USER_MAIL_LOG
APEX_030200  APEX_MAIL_QUEUE                WWV_FLOW_USER_MAIL_QUEUE
APEX_030200  APEX_PLSQL_JOB                 WWV_FLOW_PLSQL_JOB
APEX_030200  APEX_PLSQL_JOBS                WWV_FLOW_PLSQL_JOBS
APEX_030200  APEX_SITE_ADMIN_PRIVS          HTMLDB_SITE_ADMIN_PRIVS
APEX_030200  APEX_UI_DEFAULT                WWV_FLOW_HINT
APEX_030200  APEX_USER_ACCESS_LOG           WWV_FLOW_USER_ACCESS_LOG
APEX_030200  APEX_UTIL                      HTMLDB_UTIL

22 rows selected.

Yes, unfortunately at the moment I'm doing most of my work in Apex3.x - I feel so dated!

Tuesday, 4 January 2011

Adding tooltips to your APEX report

There are a number of ways to publish tooltips in your application, many of them much more verbose than they need to be.

Some of them implement fairly fancy JavaScript and CSS, but there is a simple way to plug in the default tooltip behaviour into your Apex reports.

When you edit your report column attributes, add the following code into the HTML expression.

<span title="#MY_TOOLTIP_COLUMN#">#MY_COLUMN#</span>

These attributes typically have decent help in regard to the sort of coding examples you can apply.
So this setup places the data from the selected column my_tooltip_column, and displays the value in my_column as you'd normally expect.

And is the display from Google Chrome:
Simple but effective - and flexible.

See a variation on this example here.

Wednesday, 29 December 2010

Basic Apex scripting - show/hide & labels

Sometimes the scripting requirements for an Oracle Apex page are fairly simple, yet determining the required modifications can be frustrating, particularly for a beginner in either Apex or HTML behaviours.

Recently I had the requirement of showing or hiding both the label and input item, depending on the selection within a select list.
So with this example, let's say my requirement is to hide the "Other Description" label and input item if "My select list" equals "- Select me -"
Otherwise, display the items and as an added bonus - set the label to the value of the selected list item.

First I need to modify the label so I have the ability to reference it in my JavaScript. So I edit my P1_OTHER_DESCRIPTION field and extend the HTML Table Cell Attributes in the Label section (not the Element section).
Here I added id="label_other"

Now I can define a script to do my work. It's highly likely this script will be used solely on this page so there's no real harm in adding it directly to the page attributes - unless you have a dedicated JavaScript file you add your scripting code.

So this would be added to the page footer text:
<script language="JavaScript" type="text/javascript">
<!--
function toggleOtherDesc(){
  $f_Hide_On_Value_Item('P1_MY_SELECTLIST',['P1_OTHER_DESCRIPTION','LABEL_OTHER'],'hide_desc');

  //I could also change my actual label, for instance to the value of my select list input item
  document.getElementById('LABEL_OTHER').innerText = $v('P1_MY_SELECTLIST'); 
}
toggleOtherDesc();
//-->
</script>
Some points to note here

  • $f_Hide_On_Value_Item is a pre-defined function you can call to hide a list of items based on the value of another. Its behaviour is documented online here. In this case I listed both the label I created an id for plus, the item name - surrounded by square brackets as to define an array.
  • 'hide_desc' is the value I've set in this case when the input description is '- Select me'
  • .innerText allows me to set the descriptive label, as long as I supply the id I defined for the label, not the item name you see in the Apex builder.
  • $v will return the value in the field, as it would be posted. This is also documented in the JavaScript API reference page.
  • The highlighted line 9 means the function will be called when you open the page, in this case after it's rendered. That way the fields will be shown/hidden depending on the set value in the select list.

Lastly, I can modify the P1_MY_SELECTLIST item to call the JavaScript each time the selection changes.
So I add onChange="javascript:toggleOtherDesc();" to the HTML Form Element Attributes in the Element section.

So the final product will change the label to the selected value in the select list, or hide the label and input field if '- Select me -' is chosen.
There you have it!

Thursday, 23 December 2010

Holiday season cometh, want to decorate your laptop?

It's almost a long weekend. Awesome!

Firstly, I'd like to offer a brief sentiment: some people around the world use this time to celebrate Christmas. I find it a somewhat uncomfortable time because I am one of few in my country, certainly in my circle of friends and family that do not. For those curious, recently someone else found almost the perfect words that fit my noggin. I guess I find solace in the fact that at least a third of the world's population don't celebrate it either.

However... for those of you that do, I have a great (albeit late) gift idea for you! They are called Laptop wraps, and here is a funky design example:


For those with small to large businesses, you may even consider it a great tax write-off while promoting your business. During this year's conference, we certainly had many people interested in having one designed to suit their brand. As I was going through the airport scanners recently, it even caught the favourable and approving eye of some of the security staff. Here is my laptop -


So if you want one (or many), my sister, Vicki, is in the process of populating her website full of various ideas along the same concept. It doesn't matter where in the world you live, you can order one of these; and/or ask her to help design one to suit your business or taste. So give it a visit: ArtWraps.com.au

They're pretty easy to apply, I used a ruler, some scissors, credit card, and a screen-cloth (which you can see in the photo)

I think you'll agree the final product looks a lot better than advertising for the company who built your chosen laptop. And for those consultants out there, what better way to promote your brand. I'm getting comments everywhere asking about it (and yes, sis, I'm letting them know about you ;-)

Maybe if you're a complete Oracle/Java fanboi, you could borrow a design from here ;-)
As a little extra plug, she has another website promoting her graphic design business, she's been doing all sorts of design activities and sign-writing for years - www.grovewesley.com

Anyway, I hope you all enjoy whatever it is you choose to do this time of year, and make sure you have a relaxing time doing it. Being around 35C here in the southern hemisphere, I won't be far from the beach or a pool.

Happy holidays!

Wednesday, 22 December 2010

Modifying Apex Tab behaviour

Today I was having a minor battle with tabs in Oracle Apex (3.2).

Sometimes you don't necessarily want it to submit the page when you click on a tab, so I was having a think about options to override the functionality.

I found an interesting discussion here on OTN, but I came up with something else involving On Demand processes. I'm still deciding whether it's an overkill for my situation, but I thought I'd post it as it may help someone else one day.

The solution involved :
  1. Current tab page template
  2. Script on page zero
  3. On-demand page process
My original "Current Tab" in my page template looked like this:
<td class="t9tabCurrent">
<a href="#TAB_LINK#" class="t9tabCurrent">#TAB_LABEL#</a>
#TAB_INLINE_EDIT#
</td>
I modified it to:
<td class="t9tabCurrent">
<a href=javascript:tabNav("#TAB_LINK#") class="t9tabCurrent">#TAB_LABEL#</a>
#TAB_INLINE_EDIT#
</td>

This calls a script I defined on page zero, passing through the original #TAB_LINK# code.
<script language="JavaScript">
<!--
function tabNav(p_orig)
{
  var get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=tab_target',$v('pFlowStepId'));
    get.addParam('x01',p_orig);
    vReturn = get.get();
    window.location = vReturn;
}
-->
</script>
The script will catch any click on the tab set. It takes the #TAB_LINK# substitution value and sends it to the on-demand process for processing. Then it re-directs the page to the resulting vReturn value.

My on demand process just encapsulates the code, so it's a call to a package I have defined. The g_x01 variable is the value I added in the AJAX call :
htp.p(my_pkg.tab_target(apex_application.g_x01));
This function definition simply replicates existing behaviour, but without the page submit.

FUNCTION tab_target
  (p_source  VARCHAR2)
  RETURN VARCHAR2 IS
-- Replicate tab functionality, but not as a submit
  lc_target  VARCHAR2(200);
  lc_delim   VARCHAR2(1) := q'[']';
  ln_session NUMBER := nv('SESSION');
  ln_app_id  NUMBER := nv('APP_ID');
  lc_debug   VARCHAR2(5) := v('DEBUG');
BEGIN
  SELECT 'f?p='||ln_app_id||':'||tab_page||':'||ln_session_id||'::'||lc_debug||':' -- essentially existing behaviour
  INTO  lc_target
  FROM  apex_application_tabs
  WHERE application_id = ln_app_id
  AND   tab_name = SUBSTR(p_source -- obtains T_HOME from -- javascript:doSubmit('T_HOME')
                         ,INSTR(p_source,lc_delim)+1
                         ,INSTR(p_source,lc_delim,1,2)-1-INSTR(p_source,lc_delim));

  RETURN lc_target;
END tab_target;
You could extend this to do whatever you like, depending on which tab has been pressed. I know in the past I've considered wanting to pass parameters on tab press...

Hopefully all the code is displayed ok, I'm having trouble finding an easy way to paste html examples into blogspot. I'm happy for any suggestions on that matter...

So, is anyone still working or reading blogs right now, or am I one of few? ;-)

Thursday, 2 December 2010

The bar has been raised

One day, I'd like to see something like this at an Oracle event.



Sure, it might be a little difficult if it's live, but I'm sure the technology will get there. Perhaps we'll see more of this type of thing once our broadband network gets up to scratch.

On a side note, look out for circles that do wild things - Japan in the 40s (medium red dot), China in the 50s (big red dot), Rwanda in the 90s (little blue dot), Middle East in the late 90s (green dots)... sense a trend?

Apparently Hans Rosling has some good TED talks, I might have to look those up.

Spotted at Pharyngula