8 Replies Latest reply: May 24, 2013 4:28 AM by Patrick Wolf-Oracle RSS

    tabular AJAX on a region plug in

    Sentinel
      I'm trying to build a region plugin from which I want to perform some tabular AJAX operations.

      The plugin region uses a developer supplied SQL statement to build out a list of objects which may be manipulated by the user. I want to JavaScript which manipulates to objects to return the results to the database via an AJAX call. However, whenever I attempt to add parameters to the htmldb_Get call with the add method that reference non page items, the get method responds with an HTML page containing the following error text:

      <b>Unexpected error, unable to find item name at application or page level.
      Error
      ERR-1002 Unable to find item ID for item "Pxx_ITEM_NAME" in application "110"</b>

      How can data be returned to the region plugins ajax callback function without requiring a defined application or page item?

      Assuming the following code where ajax_identifier is the result of a call to apex_plugin.get_ajax_identifier:
      var get = new htmldb_Get(null,$v('pFlowId'),'PLUGIN=ajax_identifier',$v('pFlowStepId');
      I've tried the following snippets:
      get.add('f01','some value');
      get.add('x01','some value');
      and
      get.add('Pxx_PAGE_ITEM','some value');
      Only this last one works as long as Pxx_PAGE_ITEM is an existing page item or global application item. However, what I want to do is return an array of values as though I were performing a custom Multiple Record Update and access them from the ajax call back function.
        • 1. Re: tabular AJAX on a region plug in
          trent
          Sentinel wrote:
          I've tried the following snippets:
          get.add('x01','some value');
          In this case, I think what you are looking for is:
          get.addParam('x01','some value');
          From the item level help, it seems that get 10 possible attributes much like on demand processes:
          The AJAX Procedure callback behaves the same way as an On-Demand process and can access the generic apex_application.g_x01 - g_x10 global variables to transfer data from the browser to the back end. It can also read and set session state as an On-Demand process does.
          • 2. Re: tabular AJAX on a region plug in
            Patrick Wolf-Oracle
            Hi Sentinel,

            I would suggest that you have a look at the code of the region type plug-in "Funnel Chart" at http://apex.oracle.com/plugins
            which I think is a good starting point to learn about region plug-ins and in particular about AJAX callbacks for region type plug-ins.

            For example I think it's better to use apex.jQuery.ajax instead of htmldb_Get because that will not block your browser with a synchronous call.
            In \source\com_oracle_apex_fc_funnel.js you will find the following call.
              // Reads the chart data with an AJAX call and calls pSuccessCallback when done
              function retrieveData(pSuccessCallback) {
                apex.jQuery.ajax({
                  dataType: "text",
                  type: "post",
                  url: "wwv_flow.show",
                  traditional: true,
                  data: {
                    p_request: "NATIVE="+pOptions.ajaxIdentifier,
                    p_flow_id: $v('pFlowId'),
                    p_flow_step_id: $v('pFlowStepId'),
                    p_instance: $v('pInstance'),
                    x01: 'my value' },
                  success: pSuccessCallback });
              }; // retrieveData
            If you want to set additional "generic" parameters you can use x01 - x10 as trend already mentioned. In you plug-in code just use apex_application.g_x01 - g_x10 to access those values.

            Regards
            Patrick
            -----------
            My Blog: http://www.inside-oracle-apex.com
            APEX Plug-Ins: http://apex.oracle.com/plugins
            Twitter: http://www.twitter.com/patrickwolf
            • 3. Re: tabular AJAX on a region plug in
              Sentinel
              Trent, Patrick,

              Thanks for the help. The .addParam method is what I needed to get this to work. Patrick, I plan to take a look at your asynchronous suggestion as well, but for my situation I think the synchronous solution using htmldb_Get is better, since all I'm doing is posting data back to the DB.
              • 4. Re: tabular AJAX on a region plug in
                807208
                I've been looking for the region type plug-in "Funnel Chart" at http://apex.oracle.com/plugins but it seems it´s not there any longer, is there any other place I can find it?
                • 5. Re: tabular AJAX on a region plug in
                  Patrick Wolf-Oracle
                  Hi,

                  do you want to use the "Funnel Chart" plug-in in your application, or are you just looking for a blue print example on how to write a region type plug-in?

                  Regards
                  Patrick
                  -----------
                  Member of the APEX development team
                  My Blog: http://www.inside-oracle-apex.com
                  APEX Plug-Ins: http://apex.oracle.com/plugins
                  Twitter: http://www.twitter.com/patrickwolf
                  • 6. Re: tabular AJAX on a region plug in
                    807208
                    I´m just looking for a blue print example on how to write a region type plug-in that uses the ajax callback function, I was hoping for that one or any other...
                    • 7. Re: tabular AJAX on a region plug in
                      807208
                      I just found the example at
                      https://www.evernote.com/shard/s1/note/e1fa3884-8aaf-42d4-bd1f-6f875823504b/sstryker58/Stews_Apex_tips#st=p&n=e1fa3884-8aaf-42d4-bd1f-6f875823504b
                      just in case somebody else was looking for it.
                      • 8. Re: tabular AJAX on a region plug in
                        Patrick Wolf-Oracle
                        Hi,

                        I would suggest to have a look at the "Flot Pie Chart" region type plug-in which is used in our packaged applications (ie. P-Track). It's one of our latest region type plug-ins which contains all the necessary code like flexible region SQL statement, AJAX, security and Refresh support.

                        To get it, go to

                        1) apex.oracle.com
                        2) Application Builder
                        3) Click Create
                        4) Pick "Packaged Applications"
                        5) Pick "P-Track" and install it
                        6) After installation go again to "Packaged Applications" and pick "P-Track"
                        7) Click the "Manage" button and pick "Unlock Application"
                        8) Go to the installed P-Track application
                        9) Go to Shared Components -> Plug-ins
                        10) Export the "Flot Pie Chart" plug-in to install it into your own application

                        Regards
                        Patrick
                        -----------
                        Member of the APEX development team
                        My Blog: http://www.inside-oracle-apex.com
                        APEX Plug-Ins: http://apex.oracle.com/plugins
                        Twitter: http://www.twitter.com/patrickwolf