4 Replies Latest reply on Feb 13, 2013 9:26 AM by 458347

    Binding items of a form to a pl sql object

      Hi all,
      we successfully use apex 4.2 for our application development.
      In our last development we are in a service oriented context. Services are exposed as "web services" and so we need to work "heavily" with xml.

      We have registered an xml schema using DBMS_XMLSCHEMA.registerSchema setting genType to "true". Pl sql types have been successfully generated.
      We can serialize and deserialize xml from this pl sql object.

      Now, we have to show in a web page the data contained in an xml (from that xml schema).
      Than users can edit this data from the web page, do a submit and we have to serialize again data in xml.
      Eventually we have to save the xml in an xmltype column of a table.

      We could try these steps:

      1) we can deserialize the pl sql object from the xml (easy)

      2) show data in a web page and manage the submit: this could be quite easy if we could bind the items in the form to the properties of the pl sql object.
      However this does not seem to be supported from Apex.

      3) Serialize xml from the pl sql object (easy)

      Any suggestions on point 2?

      Thank you very much.

      Edited by: user455344 on 12-feb-2013 7.28
        • 1. Re: Binding items of a form to a pl sql object
          Jorge Rimblas
          Hi Stefano,
          Have you tried a Page Process that maps the page items to a procedure?

          Something like this:
             item1 => :P1_ITEM1
           , item2 => :P1_ITEM2
           , item3 => :P1_ITEM3
          Then your procedure can handle the necessary steps.
          • 2. Re: Binding items of a form to a pl sql object
            Hi Jorge,
            thank you for your response!
            What you suggest is the standard solution which requires a lot of coding for a large object and it solves only "the submit" problem.
            I have to repeat the same logic to fill the form items before to show the web page.

            I'm searching for a "binding" features (such as exists in almost all java web frameworks: for example spring mvc or jsf) to binding form data to a backing form object (in this case a pl sql object). However I think that a similar feature in Oracle Apex doesn't exists. It seems that Apex only allows to bind the values of the items of a form to the columns of a table.However In my application I work with pl sql object created from xml data and I have not a table!

            Thank you very much.
            • 3. Re: Binding items of a form to a pl sql object
              Jorge Rimblas
              Ok, got it. I suspected you were looking for something a little more dynamic.

              You're correct, APEX doesn't have such feature yet.

              This is still more code than you may want, but would something like this work:
              -- FETCH Process
                l_page_base := 'P1_';
                for c in (select column_name, column_value from my_table)
                     apex_util.set_session_state(l_page_base || c.column_name, c.column_value);
                end loop;
              You'll need all the items created on the page of course, but it's possible to cut down on the code and make the fetch a little more dynamic.

              Then in the Submit I can do an apex_utl.get_session_state(item) and also loop through the elements.

              I've also used this technique.. but it was a pain as I was re-inventing the wheel completely.
              var options = { 
                  url:       'http://URL_PROCEDURE'
              // The Form "SAVE/SUBMIT" button would NOT submit the page and instead call this code
                , $(this).serialize()
                , function (pJSON) {processResult(pJSON);}
                , "text");
              function processResult (pJSON) {
                 var resp = $u_eval('(' + pJSON + ')');
                 if (resp.row[0].status == 'SUCCESS') {
                     window.location = 'f?p=&APP_ID.:SUCCESS_PAGE:0:';
                 else {
                     $('#uSuccessMessage').html((ie)?resp.row[0].error : resp.row[0].htmlError);
                     // if get got an item, set the focus on it
                     if (resp.row[0].item) {
                       $('#' + resp.row[0].item).focus();
              With this technique, the serialize passes value pairs in the URL to URL_PROCEDURE with all the fields on the form.
              It still required a lot of code and you're not really using APEX at this point any more.

              Good luck.
              • 4. Re: Binding items of a form to a pl sql object
                Hi Jorge,
                thank you for your suggestions!

                Eventually I will wait for a new feature which supports my requirement in a future release of Apex . Meanwhile I will use "the standard way".

                Thank you

                Edited by: user455344 on 13-feb-2013 1.26