1

I am having an issue with Oracle ApEx Collections and unsure why I am not seeing the results that I thought I would.

Firstly, I am using Oracle ApEx v3.0

I basically have the following setup as described in this example with regards to preserving checkboxes from Joel Kallman, i.e.:

http://joelkallman.blogspot.com.au/2008_03_01_archive.html

Th describe my scenario, I resent the user with a list of records by where they select any number of checkboxes, using Joel's example, the records selected are stored within the apex collection 'EMP_COLLECTION'.

Now all this seems to be storing correctly within the 'EMP_COLLECTION' but when I attempt to access these stored values from within the collection, within the PL/SQL region that is a jQuery UI dialog, I can't seem to obtain the values.

Now the page has not been submitted at this point. So when the user selects a number of checkboxes that are being ajax stored in the backend into the 'EMP_COLLECTION', the user then presses a button that calls a javascript function that basically performs a .dialog('open') call, which all works fine.

This then calls my PL/SQL region block where in the Region Header, I have defined the following:

<div id="dialog-1up-br" title="Requests - No Email Address"><img src="#WORKSPACE_IMAGES#info.gif" height="30" width="30"/>
  Please Note: You are receiving this notification as a valid email address is not available for: <br/><br/>

My region source for this PL/SQL Region block is:

BEGIN
  htp.p('<ul>');
  FOR i_rec IN ( SELECT a.c001 staff_id
                 FROM   apex_collections a
                 WHERE  a.collection_name = 'EMP_COLLECTION') LOOP
    htp.p('<li>'||i_rec.staff_id ||'</li>');
  END LOOP;
  htp.p('</ul>');
END;

So based on this info above, when my jQuery UI Dialog box appears based on this PL/SQL Region, my region header info appears correctly but nothing appears below it, based on my region source PL/SQL?

Is it because I have not actually submitted my page as I can see my collection within my session variables and it has the correct info?

halfer
  • 19,824
  • 17
  • 99
  • 186
tonyf
  • 34,479
  • 49
  • 157
  • 246
  • Do you have the truncate collection set up at any point? – Tom Sep 06 '12 at 11:47
  • Hi Tom, I will take a look but I don't believe so. So are you saying based on your question that what I am attempting to do, should actually work? See my comment below to Tony's response re: iframe. Thanks. – tonyf Sep 06 '12 at 11:56

4 Answers4

2

If the PL/SQL region is part of the current page then its contents were rendered when the page loaded. When you "reveal" it using Javascript it is not refreshed, it still shows what it showed originally.

If you used a report region instead of a PL/SQL region you could dynamically refresh it from Javascript. You just need a special report template that constructs a list instead of a table.

Since you are using APEX 3.0, refreshing a report region may not be so simple (I can't remember for sure). In that case, maybe you could construct the entire HTML of the region in an on demand process and return it, then your Javascript can call the on demand process and populate the (HTML) region with the HTML returned by the process.

Tony Andrews
  • 129,880
  • 21
  • 220
  • 259
  • Hi Tony, my report with the checkboxes is actually being called into the main page via an iframe, so it is in the iframe where I am performing the apex collection processing via javascript. Even though I am processing this via an iframe based on another page, I still would've thought that I should have access to the overall 'EMP_COLLECTION' from any page within my Apex session - does this sound right to you? Thanks. – tonyf Sep 06 '12 at 11:55
  • Yes you should, but the region where you are trying to show the collection data is showing what was there when its page loaded, not what is there now. It needs "refreshing", but you can't refresh a PL/SQL region without reloading the page. – Tony Andrews Sep 06 '12 at 11:57
  • So Tony, is there not anyway of doing what I need to do, somehow? Not sure what to do, with regards to your main answer above. FYI, I am using Oracle ApEx 3.0.1. Could I possibly use jQuery to refresh my data based on oracle apex colletion and then feed that info into a .html() ? – tonyf Sep 06 '12 at 12:01
  • Another page in the iframe is indeed able to access the collection. Collections are stored per session, so this should be fine. However! If you are generating the iframe code on page load, it may be that the src you are referencing there is already loaded! In that case your page will indeed be empty. Best check this through a DOM inspection tool (if you indeed generate the iframe code beforehand): when your page has loaded, go to the iframe, click through to its contents -> if there are contents then it's already too late of course. – Tom Sep 06 '12 at 12:04
  • APEX 3.0?! Not sure what exactly could be done back then in terms of refreshing a report region; I believe that if it was enabled for PPR than it was possible to refresh it somehow by calling the same Javascript that APEX itself used to do the pagination. Another idea about to be added to my answer... – Tony Andrews Sep 06 '12 at 12:08
0

Thanks to Tony and Tom once again for their assistance.

As was suggested, I basically performed what was outlined here:

Since you are using APEX 3.0, refreshing a report region may not be so simple (I can't remember for sure). In that case, maybe you could construct the entire HTML of the region in an on demand process and return it, then your Javascript can call the on demand process and populate the (HTML) region with the HTML returned by the process.

Basically I used an on demand process to obtain required result set, which I called from a JavaScript function, triggered from the "Submit" button on my page. Using now a HTML region, where I have set up both my region header and region footer, I simply return my result set into my dialog by using $('#div-id').html(gReturn) from my on demand process.

All worked fine.

halfer
  • 19,824
  • 17
  • 99
  • 186
tonyf
  • 34,479
  • 49
  • 157
  • 246
0

I'll just chip in aswell. :-)
Honestly, the only thing which went awry is the point at which your iframe was rendered. There are several things you could do about that:

  • Create the iframe on render, but don't set its source. When the button is clicked, set the source, then .dialog
  • Don't create the iframe on render. When the button is called, create the iframe $("div#container").html("<iframe src='...'></iframe>"), followed by .dialog
  • There is also the option of simply reloading the iframe source, see Reload an iframe with jQuery

That should solve it too without too much hassle.

Community
  • 1
  • 1
Tom
  • 6,988
  • 1
  • 26
  • 40
0

Also, make sure that the collection name is in upper case, while creating and also while querying into it.(faced similar issue & was resolved)