1 Reply Latest reply on Apr 30, 2013 4:48 PM by leckj

    apex.server.process printing selected items from a tabular form to HTML reg

      Hi everyone, thats a long-winded explanation below,
      but its only 2 weeks since I've worked really on APEX.

      This is what I want to do:

      (1) Allow users to Select items from a tabular form based on a view based on a collection.

      (2) Inspect the g_f01 array and update the collection where user has selected
      a row.

      (3) Let the user click on a button to call PL/SQL code that loops through the
      collection and for the selected members only,print the values of the collection
      members on a separate line in an HTML text region.

      (4) Ask for confirmation,then submit the page for the update/insert of the
      relevant ORACLE tables,through a custom page process.

      From what I have read in blogs, manuals etc, and on the OTN this is what I think should be done:

      First of all, I am making 2 assumptions,which may be wrong assumptions,so please
      correct if they are not valid.

      (1) sys.htp.p commands can ONLY be run in code in the the "page rendering" section
      or from an "on demand" application process., but can't be run from a process in the "page processing"

      (2) the htp.p calls have to be in an "on demand" application process,that is called from
      a javascript function through apex.server.process().

      The returned value from apex.server.process, which should be a browser-formatted data stream is
      then printed by calling get_htmldb with the returned value as a parameter.

      This is a bit confusing as you cannot create a javascript page process, so I assume the javascript
      code will calls apex.server.process, should be somewhere in the page rendering section.

      ok, now the tabular form is working, and I can update the collection with the selected values, and
      I can choose only the selected members of the collection. I checked with apex.debug.message and the
      selected members are there.

      This is what I did next:

      (1) I created an HTML region called "Entries Summary" with a region source as
      <div class="displayEntriesItem"></div>.

      I placed it alongside the tabular form.

      (2) I created an "on demand" application process called "PRINT_SELECTED_ITEMS" which contain the code
      that chooses only the selected items from the collection and prints them using sys.htp.p. I also placed some
      apex.debug.message() there to confirm the code is ok.I also added the required htp.p<div class="displayEntriesItem">
      and </div> .

      (3) I created a button name "DISPLAY_ITEMS_HTML" with an action "Redirect to HTML" and a URL Target

      (4) I placed the following javascript procedure somewhere in the HTML header of the page:

      function PrintSelectedItems()

      {"x01":"Sent from Page 5",
      {success: function(data){alert(data);}}

      What I get from the alert message is "null", so its a success but it returns null?
      Also the apex.debug.message I placed in the "on demand" process are not running,
      so the "on demand" code is not running,
      so why does it return success?..

      No sense to continue with innerhtml etc., if I have no data...

      (5) As a further check, I created another button called "DISPLAY_ITEMS" with action defined as
      "Defined as Dynamic Action". I created a dynamic action called "Execute on demand Code",with action
      "Execute JavaScript code" and Fire when Event is true, Fire on Page Load.

      The JavaScript code is
      function PrintSelectedItems()
      var r = confirm("In print selected items: On demand javascript");
      {"x01":"Sent from Page 5",
      {success: function(data){alert(data);}}

      In this case, its worse as not even the confirm message does not execute. I see no error in the Firebug console..

      Really need some help here, as there are no error messages to work on.

        • 1. Re: apex.server.process printing selected items from a tabular form to HTML reg
          Hi, just an update, at least now I have an error message on the first button,
          there was a condition that I left over preventing it to work,
          I have also amended the JavaScript code removing " from the "dataType"

          Its now

          function PrintSelectedItems()
          var r = confirm("In print selected items");
          {"x01": "Sent from Page 5",
          dataType: "text"},
          {success: function(data){alert("here->" + data);}}

          and I get Error: parsererror - SyntaxError: JSON.parse: unexpected character