com.arsdigita.cms.ui
Class DomainObjectRenderer

java.lang.Object
  extended bycom.arsdigita.bebop.Completable
      extended bycom.arsdigita.bebop.SimpleComponent
          extended bycom.arsdigita.bebop.TextStylable
              extended bycom.arsdigita.bebop.BlockStylable
                  extended bycom.arsdigita.bebop.SimpleContainer
                      extended bycom.arsdigita.cms.ui.DomainObjectRenderer
All Implemented Interfaces:
Cloneable, com.arsdigita.bebop.Component, com.arsdigita.bebop.Container, com.arsdigita.util.Lockable
Direct Known Subclasses:
ContentItemRenderer

Deprecated. Use DomainObjectXMLRenderer instead

public class DomainObjectRenderer
extends com.arsdigita.bebop.SimpleContainer

Version:
$Id: //cms/dev/src/com/arsdigita/cms/ui/DomainObjectRenderer.java#11 $
Author:
Stanislav Freidin
See Also:
A Bebop component that takes a {@link DomainObject} and renders it as XML. The XML can then be styled with XSL in order to insert the object's properties into the page.

The XML generated by this component will follow the following pattern:


 <cms:domainObjectRenderer oid="main_object_oid">
   <attributeOne>foo</attributeOne>
   <attributeTwo>bar</attributeTwo>
   <roleReferenceOne oid="child_object_oid">
     <otherAttribute>baz<otherAttribute>
     ...
   </roleReferenceOne>
   ...
 </cms:domainObjectRenderer>
 

The object which the DomainObjectRenderer should render is supplied by a {@link DomainObjectSelectionModel}. Thus, an {@link com.arsdigita.kernel.ui.ACSObjectSelectionModel}, an {@link com.arsdigita.cms.ItemSelectionModel}, or any other subclass of {@link DomainObjectSelectionModel} can be used. For example,

 String type = "com.arsdigita.kenel.User";
 ACSObjectSelectionModel model = new ACSObjectSelectionModel (
   type, type, "item_id");
 page.addGlobalStateParam(model.getStateParameter());
 page.add(new DomainObjectRenderer(model));

 

Advanced notes:

The {@link #setDepth} method controls how detailed the XML will be. At depth 1, only the attributes of the main object will be rendered. At depth 2, the attributes of the main object as well as the children of the main object will be rendered. At depth 3, the children as well as the grandchildren will be rendered... and so on. The default depth is 2.

The XML-generating code is aware of loops. Any sub-object which has already been rendered in XML will be rendered as a stub. For example:


 ...
 <textAsset oid="[com.arsdigita.cms.TextAsset:42]"
   <content>I am the text</content>
   <parent oid="[com.arsdigita.cms.TextPage:13]" />
   ...
 </textAsset>
 ...
 
Null values are not rendered at all in the XML.

Field Summary
static String CMS_XML_NS
          Deprecated.  
static String versionId
          Deprecated.  
 
Fields inherited from class com.arsdigita.bebop.BlockStylable
ABSBOTTOM, ABSMIDDLE, BASELINE, BOTTOM, CENTER, FULL_WIDTH, INSERT, LEFT, MIDDLE, RIGHT, TEXTTOP, TOP
 
Fields inherited from class com.arsdigita.bebop.SimpleComponent
m_attr
 
Fields inherited from interface com.arsdigita.bebop.Component
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE
 
Constructor Summary
DomainObjectRenderer(com.arsdigita.kernel.ui.DomainObjectSelectionModel model)
          Deprecated. Construct a new DomainObjectRenderer.
DomainObjectRenderer(com.arsdigita.kernel.ui.DomainObjectSelectionModel model, int depth)
          Deprecated. Construct a new DomainObjectRenderer.
 
Method Summary
protected  com.arsdigita.xml.Element generateXML(com.arsdigita.domain.DomainObject obj, String elementName, String elementNameSpace, int depthRemaining, Set visited)
          Deprecated. Render the specified object.
 void generateXML(com.arsdigita.bebop.PageState state, com.arsdigita.xml.Element parent)
          Deprecated. Generate XML for the domain object supplied by the selection model.
 com.arsdigita.xml.Element generateXMLElement(com.arsdigita.domain.DomainObject obj)
          Deprecated. Generate XML when you don't have a PageState, only the item
 com.arsdigita.xml.Element generateXMLElement(com.arsdigita.bebop.PageState state)
          Deprecated. Generate XML for the domain object supplied by the selection model.
 int getDepth()
          Deprecated. Return the current depth.
 com.arsdigita.domain.DomainObject getDomainObject(com.arsdigita.bebop.PageState state)
          Deprecated. Return the current domain object
 com.arsdigita.kernel.ui.DomainObjectSelectionModel getSelectionModel()
          Deprecated. Return the current selection model, which will supply the domain object
 void setDepth(int depth)
          Deprecated. Set a new depth.
 void setDomainObject(com.arsdigita.bebop.PageState state, com.arsdigita.domain.DomainObject obj)
          Deprecated. Select a new domain object
 void setSelectionModel(com.arsdigita.kernel.ui.DomainObjectSelectionModel model)
          Deprecated. Set the selection model which will supply the domain object
 
Methods inherited from class com.arsdigita.bebop.SimpleContainer
add, add, children, contains, generateChildrenXML, generateParent, get, getNamespace, getTag, indexOf, isEmpty, setNamespace, setTag, size
 
Methods inherited from class com.arsdigita.bebop.BlockStylable
setBorder, setBorder, setBorderColor, setHorizontalAlignment, setMargin, setMargin, setPadding, setPadding, setVerticalAlignment
 
Methods inherited from class com.arsdigita.bebop.TextStylable
setBackgroundColor, setColor
 
Methods inherited from class com.arsdigita.bebop.SimpleComponent
clone, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, lock, register, register, respond, setAttribute, setClassAttr, setIdAttr, setKey, setMetaDataAttribute, setStyleAttr, setVisible
 
Methods inherited from class com.arsdigita.bebop.Completable
addCompletionListener, fireCompletionEvent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.arsdigita.bebop.Component
getClassAttr, getIdAttr, getKey, getStyleAttr, isVisible, register, register, respond, setClassAttr, setIdAttr, setKey, setStyleAttr, setVisible
 
Methods inherited from interface com.arsdigita.util.Lockable
isLocked, lock
 

Field Detail

versionId

public static final String versionId
Deprecated. 
See Also:
Constant Field Values

CMS_XML_NS

public static final String CMS_XML_NS
Deprecated. 
See Also:
Constant Field Values
Constructor Detail

DomainObjectRenderer

public DomainObjectRenderer(com.arsdigita.kernel.ui.DomainObjectSelectionModel model)
Deprecated. 
Construct a new DomainObjectRenderer.

Parameters:
model - Supplies the domain object to be rendered

DomainObjectRenderer

public DomainObjectRenderer(com.arsdigita.kernel.ui.DomainObjectSelectionModel model,
                            int depth)
Deprecated. 
Construct a new DomainObjectRenderer.

Parameters:
model - Supplies the domain object to be rendered
depth - The object traversal will be limited to this depth
Method Detail

getDepth

public int getDepth()
Deprecated. 
Return the current depth. The depth is a measure of how detailed the generated XML will be.


setDepth

public void setDepth(int depth)
Deprecated. 
Set a new depth. The depth is a measure of how detailed the generated XML will be.


getSelectionModel

public com.arsdigita.kernel.ui.DomainObjectSelectionModel getSelectionModel()
Deprecated. 
Return the current selection model, which will supply the domain object


setSelectionModel

public void setSelectionModel(com.arsdigita.kernel.ui.DomainObjectSelectionModel model)
Deprecated. 
Set the selection model which will supply the domain object


getDomainObject

public com.arsdigita.domain.DomainObject getDomainObject(com.arsdigita.bebop.PageState state)
Deprecated. 
Return the current domain object

Parameters:
state - the request-specific page state

setDomainObject

public void setDomainObject(com.arsdigita.bebop.PageState state,
                            com.arsdigita.domain.DomainObject obj)
Deprecated. 
Select a new domain object

Parameters:
state - the request-specific page state
obj - the DomainObject which will be selected into the selection model

generateXML

protected com.arsdigita.xml.Element generateXML(com.arsdigita.domain.DomainObject obj,
                                                String elementName,
                                                String elementNameSpace,
                                                int depthRemaining,
                                                Set visited)
Deprecated. 
Render the specified object.

Parameters:
obj - the DataObject to be rendered
elementName - the name for the current element
elementNameSpace - the namespace for the current element
depthRemaining - if 0, render the object stub and return. Otherwise, recurse
visited - a set of all previously visited objects. If the object is already in the set, render the object stub and return.
Returns:
the generated XML element

generateXMLElement

public com.arsdigita.xml.Element generateXMLElement(com.arsdigita.bebop.PageState state)
Deprecated. 
Generate XML for the domain object supplied by the selection model.

Returns:
the generated element

generateXMLElement

public com.arsdigita.xml.Element generateXMLElement(com.arsdigita.domain.DomainObject obj)
Deprecated. 
Generate XML when you don't have a PageState, only the item

Parameters:
obj - the item to render

generateXML

public void generateXML(com.arsdigita.bebop.PageState state,
                        com.arsdigita.xml.Element parent)
Deprecated. 
Generate XML for the domain object supplied by the selection model.



Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2352 UTC