7 Replies Latest reply on Nov 27, 2014 1:33 AM by Scott Wesley

    Free-form page formatting

    User formerly known as 1622096

      I've been trying to search on this but don't really know even what keywords to use, so forgive me if this has been asked and answered before.

       

      I've been using ApEx for a few months, and while I can easily produce pages that look like one of the ApEx templated pages, i.e. Tabular reports, standard HTML forms, master/detail reports, etc, I'd like to know the best way to create a webpage that uses data from a table in a totally customized way.  What I'd like to do is use the "blank page" template, but then be able to select data from a table (one single result) and have that data available to me as needed as I build the HTML for the page.  I can't seem to figure out how to select the data and have it available (in session variables or otherwise) without using a report template.  Using a report region is too restrictive and inflexible.

       

      One solution I've seen is to build a PL/SQL function that returns the HTML coding along with the data from the database.  I dislike this solution because it transfers all the formatting of the page away from ApEx.  It's difficult to maintain that kind of HTML code.  I'd much prefer a PHP-like layout where I can inject data elements within HTML code.  Is such a thing possible with ApEx?

        • 1. Re: Free-form page formatting
          User formerly known as 1622096

          Between posting and "learning", I found the Dynamic Content Region page type which along with the htp package is pretty much what I was looking for.

          • 2. Re: Free-form page formatting
            fac586

            User formerly known as 1622096 wrote:

             

            I've been using ApEx for a few months, and while I can easily produce pages that look like one of the ApEx templated pages, i.e. Tabular reports, standard HTML forms, master/detail reports, etc, I'd like to know the best way to create a webpage that uses data from a table in a totally customized way.  What I'd like to do is use the "blank page" template, but then be able to select data from a table (one single result) and have that data available to me as needed as I build the HTML for the page.  I can't seem to figure out how to select the data and have it available (in session variables or otherwise) without using a report template.  Using a report region is too restrictive and inflexible.

            What specifically is "restrictive and inflexible" about reports and report templates?

            One solution I've seen is to build a PL/SQL function that returns the HTML coding along with the data from the database.  I dislike this solution because it transfers all the formatting of the page away from ApEx.  It's difficult to maintain that kind of HTML code.

            Agreed. It's much better practice to follow the principle of separation of concerns, with the region source being the data access layer and the report and template providing the HTML structure. If forced to compromise on this, I tend to use SQL/XML to generate HTML documents/fragments. This is efficient, declarative, easy to read, and less prone to errors than equivalent HTF/HTP package PL/SQL methods. (Compare Re: check box number of layout columns with Re: Bulk Printing?)

            I'd much prefer a PHP-like layout where I can inject data elements within HTML code.  Is such a thing possible with ApEx?

            It's possible using APEX's best feature—named column report templates. Are you aware of these and how they differ from the common generic column templates? This feature is woefully under-documented...

             

            With named column report templates, APEX reports don't have to be rendered within the confines of an HTML table.

             

            If you have tried named column report templates and they do not meet your requirements, then a region plug-in could be a possible solution (although it's not clear to me exactly how this could be made different to a named column report template).

            I found the Dynamic Content Region page type which along with the htp package is pretty much what I was looking for.

            I'm surprised at that. I find using the HTF/HTP web toolkit packages very clunky and inelegant, and far from your requirement to "inject data elements within HTML code". The element methods generate really obsolete HTML (based on the unadopted HTML 3.0 specification), so you end up coding all of the elements and attributes as strings with a forest of "<"s, ">"s, "("s, ")"s, and "||"s making everything defiantly unreadable. Other than the occasional htp.p I never use them (and nor do the APEX internals these days). Named column report templates seem to be much closer to the requirement.

            1 person found this helpful
            • 3. Re: Free-form page formatting
              User formerly known as 1622096

              I'm surprised at that. I find using the HTF/HTP web toolkit packages very clunky and inelegant, and far from your requirement to "inject data elements within HTML code". The element methods generate really obsolete HTML (based on the unadopted HTML 3.0 specification), so you end up coding all of the elements and attributes as strings with a forest of "<"s, ">"s, "("s, ")"s, and "||"s making everything defiantly unreadable. Other than the occasional htp.p I never use them (and nor do the APEX internals these days). Named column report templates seem to be much closer to the requirement.

               

              Well let me restate-- this was the closest thing I've found.  That's not to say I'm happy with the htp package-- far from it!-- but it was the best I'd found in my unsupervised searchings.

               

              Now that you've given me a promising alternative, with named column report templates, there's hope for the world once again-- Thank you!  I'll start in on that right away to see what it's all about.

               

              BTW I have a pretty simple page layout that includes a handful of data elements that are scattered throughout the layout, so that's what I meant by reports being restrictive-- they're tabular in nature and that's about it.

              • 4. Re: Free-form page formatting
                User formerly known as 1622096

                fac586 -- you have LITERALLY (ok not literally, just figuratively) saved my Friggin' LIFE with this named column template business!!!!  How do I mark your post helpful x 1000??? Seriously can I buy you a coffee (or beer)!?  I went through and created a custom named column report template and had my HTML set up exactly the way I need in a matter of minutes -- a fraction of the time it took to figure out that nasty htp nonsense.  This was a huge breakthrough for me with ApEx, and again I thank you!!

                • 5. Re: Free-form page formatting
                  Scott Wesley

                  The Interactive Report Detail View is another alternative, depending on your needs.

                   

                  But I agree, the named column template is under utilised and under documented.

                   

                  Here are some other examples of this template in use

                  APEX Reports: Custom Layout with Named Column (Row Template)

                  Using Conditions with Column Templates | A little bit of everything

                  Creating Two-level Header for report

                  • 6. Re: Free-form page formatting
                    fac586

                    User formerly known as 1622096 wrote:

                     

                    fac586 -- you have LITERALLY (ok not literally, just figuratively) saved my Friggin' LIFE with this named column template business!!!!  How do I mark your post helpful x 1000??? Seriously can I buy you a coffee (or beer)!?  I went through and created a custom named column report template and had my HTML set up exactly the way I need in a matter of minutes -- a fraction of the time it took to figure out that nasty htp nonsense.  This was a huge breakthrough for me with ApEx, and again I thank you!!

                    Brilliant. It's great that you like the technique, and that you got it working immediately. A lot of people have difficulty getting their head round the concept and how it works with the rest of the report components. Beware of column order (especially if there are differences between the query column order and that in the report attributes), hidden columns, and lack of support for some column properties (like alignment).

                    • 7. Re: Free-form page formatting
                      Scott Wesley

                      I'd be interested to know if you experience any performance issues if you happen to use conditions in the row template expressions.