Oracle ADF Model and Business Components API Reference 10.1.2 B14022-01

oracle.jbo.html.databeans
Class XmlData

java.lang.Object
  extended byoracle.jdeveloper.html.WebBeanImpl
      extended byoracle.jdeveloper.html.DataWebBeanImpl
          extended byoracle.jbo.html.DataWebBeanImpl
              extended byoracle.jbo.html.databeans.XmlData
All Implemented Interfaces:
DataWebBean, DataWebBean, WebBean, WebBean

public class XmlData
extends DataWebBeanImpl

The XmlData class renders a canonical XML representation for the rows of an oracle.jbo.RowSet. Since oracle.jbo.ViewObject implements RowSet, XmlData can be used on any RowSet or View Object.

XmlData renders a canonical XML representation by iterating through the attribute defs for the initial "root" RowSet you specify when you instantiate it. It produces equivalent XML tags for each scalar attribute. When XmlData detects that an attribute is a "nested RowSet", it recurses into itself to print the nested XML for the nested RowSet. The result is an XML "tree" of elements, reflecting the deep data print of all the rows in the root RowSet, along with any nested (View Linked) detail information.

Optionally, the setStyleSheet method lets you transform the results of XmlData according to an XSLT stylesheet.

You instantiate XmlData by declaring:

 XmlData d = new XmlData (rowset);
 

No other special set up is required, however, XmlData includes funtionality to let you:

By using custom properties, you can customize your XML output without having to edit your Java classes.

If you have a View Object attribute value that contains characters requiring quotes, such as less-than (<) or ampersand (&), XmlData lets you treat it as an XML CDATA section. Within a CDATA section, you can omit quotes from characters that would otherwise require it. To treat an attribute value as a CDATA section, add a custom property to your View Object Attribute named CDATA with a value equal to "Y".

XmlData and the JSP Element Wizard

JDeveloper's JSP Element Wizard instantiates the XmlData class in a jsp:useBean tag in a .jsp file. Along with the class, the wizard also includes an ID and scope declaration set to request. If you change the scope to any other value, you will have to handle possible multithreading issues.

The JSP Element Wizard's definition of an XmlData instance includes these methods: setResultElement, setStylesheet, setMaxRows, setReleaseApplicationResources, initialize, and render. For example,

 <jsp:useBean   class="oracle.jbo.html.databeans.XmlData"  id="xmlGen"
                            scope="request" >
 <%

    xmlGen.setResultElement("Deptno");
    xmlGen.setStylesheet("myXSL.xsl");
    xmlGen.setMaxRows(10);
    xmlGen.setReleaseApplicationResources(false);
    xmlGen.initialize(application,session, request,response,out,
                 "package3_Package3Module.DeptView");
    xmlGen.render();
 %>
 </jsp:useBean>
 

The value assigned to the setReleaseApplicationResources method determines whether the Application Module is released after the XmlData Data Web Bean processes it. Typically, the value should not be set to true unless this is the last Web Bean to be processed in the JSP page.


Field Summary
 
Fields inherited from class oracle.jdeveloper.html.DataWebBeanImpl
amName, bReleaseApplication, dispAttrs, ds
 
Fields inherited from class oracle.jdeveloper.html.WebBeanImpl
application, bUsedInTag, out, page, request, response, session
 
Fields inherited from interface oracle.jdeveloper.html.WebBean
contentFrameName, defaultCaboBase, defaultCaboImageBase, defaultImageBase, defaultJSPBase, defaultNLSFormat, JS_LIBRARIES, JS_NAMEID, JSButtonConstructorLib, JSCalendarConstructorLib, JSContainerConstructorLib, JSDataConstructLib, JSModalPageConstructorLib, JSTableConstructLib, JSToolbarConstructorLib, JSTreeConstructLib, JSUtilitiesLib
 
Constructor Summary
XmlData()
           
 
Method Summary
 Document getXMLDocument()
          Returns an in-memory DOM Document for the ViewObject
 void internalInitialize()
          Internal initialize.
 void print(java.io.PrintWriter out)
          Prints the XML results to a PrintWriter.
 void render()
          Renders the Web Bean's contents to the output stream.
 void setMaxRows(int val)
          Specifies the maximum number of master rows to render.
 void setResultElement(java.lang.String elt)
          Specifies the name of the document element for the results.
 void setRowSetTag(java.lang.String tag)
          Overvie the default XML Element name to be used for the entire RowSet
 void setRowTag(java.lang.String tag)
          Override the default XML Element name to be used for each Row in each rowset.
 void setStylesheet(java.lang.String uri)
          Sets the URI of the XSLT stylesheet to (optionally) transform XML results.
 void setStylesheet(XSLStylesheet sheet)
          Sets the instance of an XSLTStylesheet object to use to (optionally) transform XML results.
 void setStylesheetParam(java.lang.String name, java.lang.String value)
           
 void setStylesheetParamXPath(java.lang.String name, java.lang.String value)
           
 
Methods inherited from class oracle.jbo.html.DataWebBeanImpl
initialize, setUsedInTag
 
Methods inherited from class oracle.jdeveloper.html.DataWebBeanImpl
clearDisplayAttributes, getApplicationFromContext, getApplicationName, getAttributeLabel, getDisplayAttributeDefs, getDisplayAttributes, getDisplayFieldRenderer, getEditFieldRenderer, getRowKey, getRowSet, getViewObjectName, handleCommit, initialize, initialize, initialize, isAppStateful, releaseApplicationResources, releaseApplicationResources, setDisplayAttributes, setDisplayFieldRenderer, setDisplayFieldRenderer, setEditFieldRenderer, setEditFieldRenderer, setReleaseApplicationResources, setRowSet, shouldDisplayAttribute
 
Methods inherited from class oracle.jdeveloper.html.WebBeanImpl
generateScriptSrc, getCookie, getOut, getRequest, getRequestVariable, getRequestVariable, getUniqueName, initBeanForJS, initBeanForJS, initBeanForJS, initialize, initialize, initialize, render, setRequestVariable, setRequestVariable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface oracle.jdeveloper.html.DataWebBean
clearDisplayAttributes, getApplicationName, getDisplayAttributeDefs, getDisplayAttributes, getDisplayFieldRenderer, getEditFieldRenderer, getRowSet, getViewObjectName, handleCommit, initialize, initialize, isAppStateful, setDisplayAttributes, setDisplayFieldRenderer, setDisplayFieldRenderer, setEditFieldRenderer, setEditFieldRenderer, setReleaseApplicationResources, setRowSet, shouldDisplayAttribute
 
Methods inherited from interface oracle.jdeveloper.html.WebBean
initialize, initialize, render
 

Constructor Detail

XmlData

public XmlData()
Method Detail

setRowTag

public void setRowTag(java.lang.String tag)
Override the default XML Element name to be used for each Row in each rowset.

Parameters:
tag - XML Element name for each Row.

setResultElement

public void setResultElement(java.lang.String elt)
Specifies the name of the document element for the results. The document element is the single, top-most, parent, enclosing tag for the document. A valid XML document must have one and only one document element.

If you do not specify a document element name, XmlData gives it the default name "Result".

Parameters:
elt - any valid XML element name.

setRowSetTag

public void setRowSetTag(java.lang.String tag)
Overvie the default XML Element name to be used for the entire RowSet

Parameters:
tag - XML Element name for rowset

setStylesheet

public void setStylesheet(java.lang.String uri)
Sets the URI of the XSLT stylesheet to (optionally) transform XML results. If you do not specify a style sheet, the raw XML results are returned.

Parameters:
uri - URI of the stylesheet. The URI can be expressed in any of these formats:
  • http://xxxx/yyy.xsl
  • /yyy.xsl
  • yyy.xsl

setStylesheet

public void setStylesheet(XSLStylesheet sheet)
Sets the instance of an XSLTStylesheet object to use to (optionally) transform XML results.


setMaxRows

public void setMaxRows(int val)
Specifies the maximum number of master rows to render. Here, master row is defined as a row in the original "root" rowset, with its "detail" rows. A detail row is defined as a nested View Linked rowset.

A suggested, useful value for the maximum is 1. If you do not specify a maximum, all master rows are returned.

Parameters:
val - number of rows to render.

print

public void print(java.io.PrintWriter out)
           throws java.lang.Exception
Prints the XML results to a PrintWriter.

Parameters:
out - target of the PrintWriter function.
Throws:
java.lang.Exception

getXMLDocument

public Document getXMLDocument()
                        throws java.lang.Exception
Returns an in-memory DOM Document for the ViewObject

Throws:
java.lang.Exception

render

public void render()
            throws java.lang.Exception
Description copied from interface: WebBean
Renders the Web Bean's contents to the output stream.

Specified by:
render in interface WebBean
Overrides:
render in class WebBeanImpl
Throws:
java.lang.Exception

setStylesheetParam

public void setStylesheetParam(java.lang.String name,
                               java.lang.String value)

setStylesheetParamXPath

public void setStylesheetParamXPath(java.lang.String name,
                                    java.lang.String value)

internalInitialize

public void internalInitialize()
                        throws java.lang.Exception
Description copied from interface: WebBean
Internal initialize. This method should be overriden by any WebBean needing to initialize some internal data after all the base class member have been initialize properly.

Specified by:
internalInitialize in interface WebBean
Overrides:
internalInitialize in class DataWebBeanImpl
Throws:
java.lang.Exception

Oracle ADF Model and Business Components API Reference 10.1.2 B14022-01

 

Copyright © 1997, 2004, Oracle. All rights reserved.