5 Replies Latest reply: Feb 4, 2013 1:31 PM by TexasApexDeveloper RSS

    How to Convert Variable containing HTML to be read as HTML in HTML region

    KylePN
      To understand the question, I have a table storing generated HTML by user and report type:
       USER      | REPORT_TYPE | HTML_GENERATED
      ----------------------------------------------------------------------------------------|
       TEST_USER |   TEST      | <HTML><head><title></title></head><BODY>TEST</BODY></HTML>   |
      On the page exists a process using a PL/SQL anonymous block which is set to "On Load Before Header". Here is a portion of it:
      SELECT HTML_GENERATED into :P2_HTML
      from LN_DOCUMENT_LABELS
      where USER = :app_user AND REPORT_TYPE = 'TEST';
      The idea is to generate all the HTML behind the scenes in another package.

      There exists a single Item on the page to store the variable into:
       P2_HTML     (Hidden) 
      Then I created an HTML region, and within that region I wanted to call in the item so I entered:
      &P2_HTML.
      The result simply displays the HTML code:
      <HTML><head><title></title></head><BODY>TEST</BODY></HTML>
      Is there a way to force it to be the result of HTML code when the page renders?
      TEST
        • 1. Re: How to Convert Variable containing HTML to be read as HTML in HTML region
          TexasApexDeveloper
          You could have a pl/sql region with code like:
          begin
            htp.p(:P2_HTML);
          end;
          That would send the html code to your browser for display.. However you might want to confirm that the HTML being produced is valid..

          Thank you,

          Tony Miller
          Ruckersville, VA
          • 2. Re: How to Convert Variable containing HTML to be read as HTML in HTML region
            fac586
            KylePN wrote:
            To understand the question, I have a table storing generated HTML by user and report type:
            USER      | REPORT_TYPE | HTML_GENERATED
            ----------------------------------------------------------------------------------------|
            TEST_USER |   TEST      | <HTML><head><title></title></head><BODY>TEST</BODY></HTML>   |
            Hopefully that's just poorly chosen sample HTML? APEX page templates already include those elements. Trying to output a complete HTML document inside an APEX page generally results in a mangled, inoperative mess.
            On the page exists a process using a PL/SQL anonymous block which is set to "On Load Before Header". Here is a portion of it:
            SELECT HTML_GENERATED into :P2_HTML
            from LN_DOCUMENT_LABELS
            where USER = :app_user AND REPORT_TYPE = 'TEST';
            The idea is to generate all the HTML behind the scenes in another package.
            In APEX it's not necessarily a good idea. Why use this approach rather than existing APEX features?
            There exists a single Item on the page to store the variable into:
             P2_HTML     (Hidden) 
            Then I created an HTML region, and within that region I wanted to call in the item so I entered:
            &P2_HTML.
            The result simply displays the HTML code:
            <HTML><head><title></title></head><BODY>TEST</BODY></HTML>
            Is there a way to force it to be the result of HTML code when the page renders?
            TEST
            Hidden page items these will always be escaped when referenced as static text substitution strings. (You may indeed have done this in previous versions of APEX at some point in the past, but there have been incremental restrictions introduced in several recent APEX versions.)

            Instead of a hidden page item, use an application item, or a Display Only page item with display Condition set to Never.
            • 3. Re: How to Convert Variable containing HTML to be read as HTML in HTML region
              KylePN
              That would definitely work instead. Thank you.
              • 4. Re: How to Convert Variable containing HTML to be read as HTML in HTML region
                KylePN
                My HTML example was basically a blank shell to get the point across. I need to develop a packing slip or order acknowledgment, and currently using the built in interactive reports and current region options everything looked awful. They want a specific look to the document, and I figured I could do this in html if I could find a way to insert the data. I can do this with what I outlined originally, but am open to any option that is better long term. Can you recommend other options to get the look and feel of a professional document?

                Kind Regards,
                Kyle
                • 5. Re: How to Convert Variable containing HTML to be read as HTML in HTML region
                  TexasApexDeveloper
                  Create an RTF file and let them upload it after manipulating it in Word? Use Ireports and PL-jrxml2pdf to build and display a pdf style report? (link to product: http://sourceforge.net/p/pljrxml2pdf/wiki/Home/)

                  Thank you,

                  Tony Miller
                  Ruckersville, VA