1
votes

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?

3
Do you have the truncate collection set up at any point?Tom
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

3 Answers

2
votes

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.

0
votes

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.

0
votes

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.