ARTICLES

Home  > Articles  >  Returning reader comments from an Oracle Reports Builder 9i report

Returning reader comments from an Oracle Reports Builder 9i Web report
By: John Adolph Palinski

Oracle's Reports Builder 9i allows the developer to easily create two types of reports: paper and Web.  Paper has been the traditional type of report, but the Web reports have a great deal of potential.  A Reports Builder Web report is a Java Server Page.  A servlet sends a dynamic HTML page to the Web browser when the report is called.  Since the report is in a Web browser rather than the previewer, the developer can use the power of HTML, JavaScript, and the Web to perform some interesting feats.  One rather interesting feature that can be added to a report is a text area.  The text area can be used to record report comments and send the comments to a particular address.  This feature allows the reader to record comments on the reviewed document page while reading the document.  The reader no longer has to bounce between the report and e-mail.  Allowing a reader to record and e-mail comments directly from a report page can be a handy communication tool.  This article will describe how to add a form, text area and a submit button to a Reports Builder 9i Web report.

It is relatively easy to add a text area to a Reports Builder 9i Web report.  Simply add the following HTML tags:

      - A form tag< FORM action=“mailto:realistic@radiks.net” name="report_comments"
                                                      method="post" encType="text/plain" >     
      - A text area tag< TEXTAREA name="comments" rows="10" cols="20">      
      - A submit button< INPUT type="submit" value="Send Comments">

Be sure to add the end tags.

You should note that the above form tag action setting has a hard coded e-mail address.  It is better and more flexible if the report reader can enter this value.  This way the reader can choose who to send the report.  This will require some additional work. You can add a JavaScript function to the report that causes the proper e-mail address to be used.  The following is a JavaScript function that performs this task:

< SCRIPT LANGUAGE="JavaScript">
< !--
function sendMail()
    {
        var dest = "mailto:" + document.report_comments.address.value;
        document.report_comments.action=dest;
        document.report_comments.submit();
    }
//-->
< /script>

The JavaScript function can be added to the beginning of the report JSP file in the Web source window.  This can occur after the< HTML> tag and before the< TITLE> tag.  You will also need to perform two additional tasks.  The first is to add an input tag that is used by the reader to enter the e-mail address.  The following tag can be used to add a text field:

< input type="text" name="address" size="30">

The next task is to call the function when the Submit button is pressed.  This will require a modification to the Form tag discussed earlier.  The action setting is replaced with an onsubmit setting.  Onsubmit executes the sendMail JavaScript function that sends the e-mail to the proper address.  The following is the modified Form tag that calls the sendMail function.  

< FORM onsubmit="sendMail()” name="report_comments">
                                                      method="post" encType="text/plain" >
 

Reports Builder has a series of default templates.  The default templates have a table located on the left side of the page.  This table is used for navigation links such as bookmarks.  This table is an excellent place to add the form.  The following figure illustrates the text area in a default template form.  Please note that the figure only displays the left column containing the text area.  The actual report is to the left of this area and is not displayed.



The template table is fairly easy to locate if you are using the Oracle templates.  Look for the Blue_d_arrow.gif.  It is on a row of the table.  The following figure displays the Reports Builder Web Source window.  It is displaying the Table tags that created the form in the above figure.  You can follow this as a template.  

Oracle Reports Builder 9i and its new Java Server Page technology offer you a powerful tool to develop Web reports.  I'm sure that you will find it easy to add a form and text area to your next report.  

Note:  The tag start and stop symbols (i.e. < and >) in this article are actually escape characters.  The escape characters were used so that the actual symbol is displayed in the document.  If you copy the tags directly from this page into the Reports Builder Web Source window, the web browser will consider them text rather than a tag.

About the Author

John Adolph Palinski is an Oracle Certified Professional developer.  He has been adjunct faculty at various institutions.  He is the author of: “Oracle9i Developer: Developing Web Applications with Forms Builder”, Course Technology, 2003; “Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analyst”, Addison Wesley, 2003; and the “Oracle Database Construction Kit”, Que, 1997.  He has also written numerous Oracle articles.  He provides various pre-developed and custom Oracle training courses through his company Realistic Software Training.  He is always on the search for interesting topics to write upon.  He can be contacted at www.oracle-trainer.com