1 2 Previous Next 15 Replies Latest reply: Aug 15, 2014 6:44 AM by Richard Legge RSS

    g_f01 session state

    2729708

      Hi,

       

      Apex 4.2

       

      I have a standard report. I want to access the values in that report from pl/sql using the apex_application.g_f01 array. However apex_application.g_f01.count is coming back as 0.

       

      I am clearly missing something, the column I am interested in is probably not storing its values in the session state, even when I set the column to be "Display as text (save session state)" it makes no difference.

       

      Please can somebody point me in the right direction?

       

      Thanks

       

      Ralph

        • 1. Re: g_f01 session state
          Richard Legge

          Hi Ralph, did you explicitly create a value for f01 as per documentation APEX_ITEM..

           

          I struggled with this until I explicitly created a hidden column and concatenated it to another column using APEX_ITEM.HiDDEN(1,ID)||col2..   Just trying to use the column on its own didn't work..

           

          my syntax was

           

          select

          apex_item.hidden(1,ID)||any_column

          from table

           

          Then your count should match the records on the screen...

           

          Rgds

          Richard

          • 2. Re: g_f01 session state
            2729708

            Hi Richard, thanks for getting back to me.

             

            I tried your suggestion, however no luck. The snippet from the sql used as the Region Source is now.

             

            select

                   APEX_ITEM.HIDDEN(1,b.subject_id)||APEX_ITEM.TEXT(2,b.subject_name) as subject_name

             

            which causes the subject_name to be displayed as

            <input type="hidden" name="f01" value="41" /><input type="text" name="f02" size="20" maxlength="2000" value="Confucious" />

             

            and the code that references the count is a debug line in a plsql dynamic action:

             

            sys_utl.log(p_message=>'Called! '||apex_application.g_f01.count);

             

            Which is still reporting 0

             

            Is there some way that the dynamic action is is a different context to the report region?

             

            Thanks again

             

            Ralph

            • 3. Re: g_f01 session state
              Richard Legge

              Hi Ralph.. Where/when are you trying to access the array? It is only available directly to PL/SQL at submit time.. If you want to access it via a Dynamic action, you will need to access it via Javascript/JQuery and call a PL/SQL on Demand process..  (I fell into exactly the same trap only last week, and one of the more experienced guys on here helped..)

               

              This is my Dynamic Action, triggered by a button push...  In this example gets only checked checkbox items..    I think,  (but you will have to try ), to get all of the array values, remove the(   .filter(":checked")     )

               

              apex.server.process('SET_BUDGET_CODES',{ 

              f01:$.map($('[name="f01"]').filter(":checked"),function(e){return $(e).val()}) 

              },{ 

              dataType:"text", 

                success:function(pData){} 

              });

               

              Then create an onDemand PL/SQL Process.. which matches the process being called above..

               

              SET_BUDGET_CODES

               

              begin

              for i in 1 .. apex_application.g_f01.count

              loop

              delete from bri_recon where bank_stmt_id = apex_application.g_f01(i);

              end loop;

              end;

               

              Hope this helps..

              Rgds

              • 4. Re: g_f01 session state
                2729708

                Hi Richard,

                 

                Still no joy. It's driving me potty.

                 

                So I started a new page, with a very simple basic 2 column report. The source of which is:

                 

                select subject_id, APEX_ITEM.HIDDEN(1,b.subject_id)||APEX_ITEM.TEXT(2,b.subject_name)  as subject_name from subjects b.

                 

                I created a pl/sql process to be executed by the javascript. Called test_ajax_process

                 

                BEGIN

                   sys_utl.log(p_message=>'Calledxx! '||apex_application.g_f01.count);

                END;

                 

                finally a dynamic action fired upon the after refresh framework event for the report region, that executes some javascript

                that looks like this:

                 

                apex.server.process('test_ajax_process',{

                f01:$.map($('[name="f01"]'),function(e){return $(e).val()})

                },{

                dataType:"text",

                  success:function(pData){}

                });

                 

                Now everything works...apart from the apex_application.g_f01.count is still 0. I don't pretend to understand that javascript, but the pl/sql process is getting called ok. And the subject_name field in the table looks like

                <input type="hidden" name="f01" value="131" /><input type="text" name="f02" size="20" maxlength="2000" value="VICTOR" />, so I would have though that f01 reference is correct.

                 

                Do you have any more ideas. I have a feeling I don't grasp something fundamental....

                 

                Cheers

                 

                Ralph

                • 5. Re: g_f01 session state
                  Richard Legge

                  Hi Ralph, I created a simple working test on APEX..  go to workspace VRS login test/test application: 291.. check page 5..  I'm not using sys_utl.log, but Im populating a page item..

                   

                  Fire the button.. It will invoke the DA, and ajax process.. The page item doesn't get actually populated until a reload, but if you check the session for that item after you hit the button, you will see that the item is set with the count of the records...

                   

                  Cheers.

                  R

                  • 6. Re: g_f01 session state
                    Sven W.

                    Apex collections are used for tabular forms. Most columns are then stored inside the collection.

                    Afaik classical reports do not use apex collections. Therefore you can't reference or count on the collection directly.

                    There are ways to have a report use collections too. The easiest would probably be to use the wizard to create a tabular form and disable all the fields. Although disabling them, might remove them from the collection. I didn't test this yet.

                     

                    Maybe you can tell us, what you want to do with the information.

                    Assuming the count returns that 23,456 rows are in the collection. Why is that info important to you?

                    • 7. Re: g_f01 session state
                      2729708

                      Hi,

                       

                      Yes I am probably trying to do something fundamentally wrong. Let me explain what I want to do.

                       

                      I have a classic report which enables the user to paginate through the result set. I also have a chart that I produce on the same page that reflects the items in the report (not the same data, but data pertinent to those items). So if the report is showing 6 lines (which 6 lines is controlled by the user by pagination), each has an ID, its those id's that I need to access before refreshing the chart (I'm simply using the count to iterate through them). The chart is produced from custom xml that is generated by a stored function. This function takes an array of IDs as its input.

                       

                      Hence what I'm currently trying to do when the report area is refreshed by user pagination is to fire a pls/sql dynamic action that builds an array of the ID's, passes this array to a function that regenerates the XML for the chart, then redraws the chart. If anybody has a better approach then please share...I'm only in week two of apex development!

                      • 8. Re: g_f01 session state
                        2729708

                        Sorry Richard, but do you have a url for that?

                        • 9. Re: g_f01 session state
                          Richard Legge

                          sure...  https://apex.oracle.com/pls/apex/f?p=4550:1:105607484524630    log in as per above.. Btw, my example is on a classic Report..   Rgds

                          Richard

                          • 10. Re: g_f01 session state
                            2729708

                            I have had a look at that, tried to edit it to make it similar to my situation, but couldn't. However what I would have done to change it to be like mine is to limit the number of rows in the report to 5 (so that pagination is enabled), then changed the triggering event from your button click, to a "refresh framework event" so that the Dynamic action would fire automatically after the user paginated, I thin this is where the problem lies.

                            • 11. Re: g_f01 session state
                              Richard Legge

                              Hi Ralph, I see what you are trying to do... I changed my report.. Firstly I gave my report a static ID (Attrributes -> static ID. (I called it MyReport   ) then I changed my Dynamic Action to fire :

                               

                              After Refresh

                              Selection Type: DOM Object

                              DOM Object: MyReport

                               

                              Ive still the alert on my DA, so each time I click to move to the next set of retrieved rows it fires. each time I see 15 Rows in my session as the value.. When it got to the last set, there were 12 rows and the session value was 12...

                               

                              Not sure why you cannot edit my page. test/test has developer privileges...

                               

                              rgds

                              • 12. Re: g_f01 session state
                                2729708

                                Hi Richard,

                                 

                                Well. I can see your one is working. Mine, not so much. I created a new page, copying exactly what you had (changes of table and column names in the query). The only thing that is different is the Template of the report where you have "standard region" and I have "reports region"...I don't have the option for a "standard region". Though when I had it as "Blank region" the dynamic event refused to fire at all...

                                 

                                But alas the .count is coming back as 0 .. still.

                                 

                                Now a big difference is that the actual output in the report for you looks perfect where you have concatenated the apex_item.hidden. Mine however is full of the tags. eg

                                <input type="hidden" name="f01" value="261" />H

                                 

                                Query source is

                                 

                                select

                                subject_id,

                                apex_item.hidden(1,subject_id)||subject_type as subject_type,

                                subject_name

                                from subjects

                                 

                                Which is generated from this query. So is this likely to be something to do with it? I dont know how to get these hidden tags not to display. Maybe its to do with the report region template...

                                • 13. Re: g_f01 session state
                                  2729708

                                  Ok! Thats now working. The column type in the report needed to be "standard report column" as to "display as text(escape html)

                                   

                                  Thanks for all your help!

                                   

                                  Ralph

                                  • 14. Re: g_f01 session state
                                    2729708

                                    Ok! Thats now working. The column type in the report needed to be "standard report column" as to "display as text(escape html)

                                     

                                    Thanks for all your help!

                                     

                                    Ralph

                                    1 2 Previous Next