This discussion is archived
5 Replies Latest reply: May 1, 2013 8:51 AM by leckj RSS

can the g_f0x variables be accessed in PL/SQL code in page rendering?

leckj Newbie
Currently Being Moderated
Hi,

I have set a button in a tabular form that runs a dynamic action made up of 2 parts in sequence:

(1) a PL/SQL code that updates a collection using g_f01 (selected items in the tabular form)
(2) a javascript that calls apex.server.process to display the selected items in a region

All this code is in the page rendering section being called from a button,and thats the only way it seems to fire PL/SQL and javascript from a button
one after the other.

I have a page process called "submit" that does a loop through the g_f01 values again and updates the collection again just to check.

Now, the PL/SQL code in the dynamic action does not see any selected values in the g_f01 array,while the code in the "submit" page process.
sees them correctly. I've used debug to check.

Question: Can the g_f0x values of a tabular form columns be accessed through a PL/SQL in page rendering, or can they
only be accessed through a page process?

If not, can the g_f0x values be saved in a global array somewhere although that will make things more complicated.



Leckraj
  • 1. Re: can the g_f0x variables be accessed in PL/SQL code in page rendering?
    jrimblas Expert
    Currently Being Moderated
    leckj wrote:
    Question: Can the g_f0x values of a tabular form columns be accessed through a PL/SQL in page rendering, or can they
    only be accessed through a page process?

    If not, can the g_f0x values be saved in a global array somewhere although that will make things more complicated.
    Hi Leckraj,
    This is the correct behavior, the g_f0x values can be accessed during rendering, but they are empty. :)

    They way to get around this is to use collections. Look into the apex_collection package.
    Collections are perfect for this, the data is saved in the DB so it's always available, but it's stored for the current user and it's session so it scales for multiuser use.

    Thanks
    -Jorge
  • 2. Re: can the g_f0x variables be accessed in PL/SQL code in page rendering?
    leckj Newbie
    Currently Being Moderated
    Hi Jorge,

    Thanks for answering,

    If only I had known, because my whole cunning plan was based on this!

    Been in APEX only for some 2 weeks, and its a whole new environment coming from the quiet forms6i way
    of doing things, and sometimes a bit strange.

    I am using collections in fact as my tabular form is based on a view based on a collection.
    However, the cells in the form only seem to be placeholders and any changes seem to be made to only the
    g_f0x arrays, and the underlying collection members have to be updated programatically.

    So if I lose the g_f0x values I cannot update the collection. chicken and eggs.

    The flow needs to run a PL/SQL to update the collection,followed by a javascript call to apex.server.process to print the values in a region.

    Yon cannot have javascript as a page process, and g_f0x values in the rendering part, so is there anywhere apart from a 2-step dynamic action,
    that we can force the run of PL/SQL code followed by javascript?

    So thats why I have seen no one doing this in APEX, should have known!

    Regards
    Leckraj
  • 3. Re: can the g_f0x variables be accessed in PL/SQL code in page rendering?
    fac586 Guru
    Currently Being Moderated
    leckj wrote:
    Hi Jorge,

    Thanks for answering,

    If only I had known, because my whole cunning plan was based on this!

    Been in APEX only for some 2 weeks, and its a whole new environment coming from the quiet forms6i way
    of doing things, and sometimes a bit strange.

    I am using collections in fact as my tabular form is based on a view based on a collection.
    However, the cells in the form only seem to be placeholders and any changes seem to be made to only the
    g_f0x arrays, and the underlying collection members have to be updated programatically.

    So if I lose the g_f0x values I cannot update the collection. chicken and eggs.

    The flow needs to run a PL/SQL to update the collection,followed by a javascript call to apex.server.process to print the values in a region.

    Yon cannot have javascript as a page process, and g_f0x values in the rendering part, so is there anywhere apart from a 2-step dynamic action,
    that we can force the run of PL/SQL code followed by javascript?
    This sounds excessively complicated. The normal APEX approach would be to submit the page, and update the collection from the tabular form <tt>apex_application.g_fxx</tt> array values in a post-submit process. The updated collection values can be displayed in a region using SQL or PL/SQL on page show without recourse to JavaScript.

    This early in your use of APEX, why are you not just using the basic technique?
  • 4. Re: can the g_f0x variables be accessed in PL/SQL code in page rendering?
    jrimblas Expert
    Currently Being Moderated
    If I understand correctly, what you're trying to do will require lots of code. You will need to "read" the fields on the form with javascript and populate something with them. Not an easy task going back and forth between js and pl/sql. It also defeats the purpose of using the APEX functionality.

    Why must it be a Dynamic Action? Couldn't you submit the page to process the changes?
    Populating a collection first and render your page based on the collection is a common technique for some complex functionality. Some of use do it all the time, there are several examples out there. BUT you must post the page (meaning Submit the page) so that your g_f arrays get populated and you can process your data. Without that, you need to read the values manually somehow with javascript.

    I understand your frustration learning APEX. It's a complicated change from GUI to web interface. You must change the way you think. This is not APEX specific is just the reality of web applications.

    -Jorge
  • 5. Re: can the g_f0x variables be accessed in PL/SQL code in page rendering?
    leckj Newbie
    Currently Being Moderated
    The reason why I want to do this is because the tabular form has many rows maybe 25-30 and extend down the page and I wanted to summarize the
    entries for the users before submitting in case the entries are not correct. The nature of the entries is a bit complicated, and I felt that it would
    be easier to help them get it right first time rather than trying to make changes later. And it involves payment.

    But as you say this is the web and I need to think differently.

    But I must say that I have learned a lot by doing it this way. 2 weeks ago, I have never written Javascript code did not know about <div> and jQuery
    collections and all that. It was interesting learning except for the day I tried to get into jQuery and Regular expressions!

    I'll give it another try using 2 buttons to run the javascript and PL/SQL separately, but if I feel its not intuitive,then you're right
    I'll work around a simple tabular form.

    Thanks for the advice Jorge and fac586.

    Leckraj

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points