com.ibm.designer.domino.xsp.api.util
Class XPagesDOMUtil

java.lang.Object
  extended by com.ibm.designer.domino.xsp.api.util.XPagesDOMUtil

public class XPagesDOMUtil
extends java.lang.Object

A utility class that allows users to perform certain operations on the DOM Model of an XPage. It is recommended to use this class when performing certain operations on an XPage like getting the value of an attribute, setting an attribute value etc.


Field Summary
static int MODE_ATTRIBUTE
           
static int MODE_COMPLEXCDATA
           
static int MODE_COMPLEXTEXT
           
static int MODE_INVALID_CDATA
           
static java.lang.String XML_NAMESPACE
           
static java.lang.String XML_NAMESPACE_PREFIX_SEP
           
protected static java.lang.String XML_PI_DATA
           
protected static java.lang.String XML_PI_TAG
           
 
Constructor Summary
XPagesDOMUtil()
           
 
Method Summary
static org.w3c.dom.Element addComplexProperty(org.w3c.dom.Element elt, java.lang.String propertyName, java.lang.String value)
          Adds a complex property to the given element.
protected static boolean checkParent(FacesDefinition definition, java.lang.String namespaceUri, java.lang.String id)
           
static void clearElement(org.w3c.dom.Element element)
          Remove all of the given element's children.
static void clearIds(org.w3c.dom.Element element)
          Set all the IDs in the given element and all it's children to null.
static org.w3c.dom.Element createChildElement(org.w3c.dom.Element parent, FacesRegistry registry, java.lang.String tag)
          Create a child control inside another element.
static org.w3c.dom.Element createElement(org.w3c.dom.Document ownerDocument, FacesRegistry registry, java.lang.String uri, java.lang.String tagName)
          Helper method to create an element.
static java.lang.String createNamespacePrefix(java.lang.String prefix)
          Creates a namespace prefix, given the control prefix.
static java.lang.String createQualifiedTagName(java.lang.String prefix, java.lang.String localName)
          Combine a prefix and local name into a qualified name.
static org.w3c.dom.Element createXPagesElement(org.w3c.dom.Document doc, java.lang.String localName)
          Creates an XPages core control element.
protected static boolean elementNeedsId(FacesRegistry registry, org.w3c.dom.Element element, org.w3c.dom.Document doc)
          Determines if the given element requires an ID in accordance with the tag's definition in the FacesRegistry.
protected static boolean elementNeedsVar(FacesRegistry registry, org.w3c.dom.Element element, org.w3c.dom.Document doc)
          Determines if the given element requires a var attribute in accordance with the tag's definition in the FacesRegistry.
static java.lang.String ensureNamespaceDeclaration(org.w3c.dom.Document doc, java.lang.String namespaceUri, java.lang.String prefix)
          Ensure a namspaceUri exists in a document.
static boolean ensureRequiredNodesExist(org.w3c.dom.Document root)
          Ensure the required document nodes exist to make this model a legal XPages form.
static void ensureUniqueIds(org.w3c.dom.Document doc, org.w3c.dom.Node root, FacesRegistry registry)
          Ensures the ids applied to the supplied node are unique in the context of the document they are being inserted into.
static void ensureUniqueIds(org.w3c.dom.Document doc, org.w3c.dom.Node root, FacesRegistry registry, boolean generateIdIfNotSet)
          Ensures the ids applied to the supplied node are unique in the context of the document they are being inserted into.
static void ensureUniqueIdsGenerateIfRequested(org.w3c.dom.Document doc, org.w3c.dom.Node root, FacesRegistry registry, boolean generateId)
          Using the given document as a reference for existing ids, ensures every element in the root has a unique id.
static void ensureUniqueVars(org.w3c.dom.Document doc, org.w3c.dom.Node root, FacesRegistry registry)
          Using the given document as a reference for existing vars, ensures every element in the given node has a unique var.
static boolean findGlobalDefAndAddDependency(java.lang.String uri, java.lang.String tagName, DesignerProject project)
          Finds a FacesDefinition for the given tag.
static void formatNode(org.w3c.dom.Node node, org.w3c.dom.ranges.Range range)
          Formats a single node
static void formatNodes(org.w3c.dom.Node[] nodes, org.w3c.dom.ranges.Range range)
          Format an array of nodes.
static java.lang.String generateUniqueId(java.util.List<java.lang.String> idList, org.w3c.dom.Element element)
          Returns a unique id candidate for the given element.
static java.lang.String generateUniqueId(java.util.List<java.lang.String> idList, org.w3c.dom.Element element, java.lang.String hint)
          Returns a unique id candidate for the given element.
static java.lang.String generateUniqueVar(java.util.List<java.lang.String> varList, org.w3c.dom.Element element)
          Returns a unique var candidate for the given element.
static java.lang.String generateUniqueVar(java.util.List<java.lang.String> varList, org.w3c.dom.Element element, java.lang.String hint)
          Returns a unique var candidate for the given element.
static java.lang.String getAttribute(org.w3c.dom.Element element, java.lang.String attribute)
          Helper method to get an attribute value.
static java.util.Map<java.lang.String,java.lang.String> getAttributeChildren(org.w3c.dom.Element element)
          Get all the "this." attribute children of a node.
static org.w3c.dom.Element getAttributeElement(org.w3c.dom.Element element, java.lang.String attribute)
          Return the element for the given attribute if it exists.
static java.util.Map<java.lang.String,java.lang.String> getAttributes(org.w3c.dom.Element element)
          Get all the attributes for an element.
static java.lang.String getDefaultPrefix()
          Returns the default namespace prefix for an XPage Core tag.
static FacesDefinition getFacesDefinition(org.w3c.dom.Element element, FacesRegistry registry)
          Return a FacesDefintion for the given element.
static java.lang.String[] getIds(org.w3c.dom.Node root, org.w3c.dom.Node nodeToExclude)
          Returns the IDs of all of the node that are a child of the given node.
static java.lang.String[] getIds(org.w3c.dom.Node startNode, org.w3c.dom.Node nodeToExclude, FacesRegistry registry, java.lang.String namespaceUri, java.lang.String id, boolean checkParent)
          Returns an array of ids that are already defined on the XPage.
static java.lang.String[] getIdsExcludeList(org.w3c.dom.Node root, java.util.List<org.w3c.dom.Node> nodesToExclude)
           
static java.lang.String[] getIdsExcludeList(org.w3c.dom.Node startNode, java.util.List<org.w3c.dom.Node> nodesToExclude, FacesRegistry registry, java.lang.String namespaceUri, java.lang.String id, boolean checkParent)
           
static int getModeForValue(java.lang.String attributeValue)
          Returns the 'mode' for a given attribute value.
static java.lang.String getNamespacePrefix(org.w3c.dom.Document doc, java.lang.String namespaceUri)
          Get the namespace prefix in use in a document of a namespaceUri.
static java.lang.String getNamespaceUri()
          Get the default namespace URI for core XPage controls
static java.lang.String getNamespaceUri(org.w3c.dom.Document doc, org.w3c.dom.Node node)
          Return the namespace uri for the given element, searching the document if necessary.
static java.lang.String getNamespaceUriForPrefix(org.w3c.dom.Document doc, java.lang.String prefix)
          Return the namespace uri associated with the given prefix, or null if there is none.
static java.lang.String getPrefix(org.w3c.dom.Document doc, java.lang.String namespaceUri, FacesRegistry registry, java.lang.String tagName)
          Return the prefix for the given namespace URI and tag name.
static java.lang.String getRootTagName()
          Get the tagname that is the root of the xsp file (view).
static java.lang.String[] getValuesOfAttr(org.w3c.dom.Node root, org.w3c.dom.Node nodeToExclude, FacesRegistry registry, java.lang.String namespaceUri, java.lang.String id, boolean checkParent, java.lang.String attrName)
          Returns the values for all occurrances of a given attribute on a given document
static java.lang.String[] getValuesOfAttrExcludeList(org.w3c.dom.Node root, java.util.List<org.w3c.dom.Node> nodesToExclude, FacesRegistry registry, java.lang.String namespaceUri, java.lang.String id, boolean checkParent, java.lang.String attrName)
          Returns the values for all occurrances of a given attribute on a given document
static java.lang.String[] getVars(org.w3c.dom.Node startNode, org.w3c.dom.Node nodeToExclude)
          Returns all of the values of the 'var' attributes on the document
static java.lang.String[] getVars(org.w3c.dom.Node startNode, org.w3c.dom.Node nodeToExclude, FacesRegistry registry, java.lang.String namespaceUri, java.lang.String id, boolean checkParent)
          Returns the values of all of the var attributes on the given document.
static org.w3c.dom.Element getViewNode(org.w3c.dom.Document doc)
          Get the view node of a given document.
static void initializeDefaultValues(org.w3c.dom.Element element, FacesRegistry registry)
          Helper method to call after an element has been created.
static boolean isComponent(FacesDefinition def, java.lang.String namespaceUri, java.lang.String id)
          Return true if the given def matches the given uri and id.
static boolean setAttribute(org.w3c.dom.Element elt, java.lang.String attributeName, java.lang.String value)
          Helper method to set an attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_ATTRIBUTE

public static final int MODE_ATTRIBUTE
See Also:
Constant Field Values

MODE_COMPLEXTEXT

public static final int MODE_COMPLEXTEXT
See Also:
Constant Field Values

MODE_COMPLEXCDATA

public static final int MODE_COMPLEXCDATA
See Also:
Constant Field Values

MODE_INVALID_CDATA

public static final int MODE_INVALID_CDATA
See Also:
Constant Field Values

XML_PI_TAG

protected static final java.lang.String XML_PI_TAG
See Also:
Constant Field Values

XML_PI_DATA

protected static final java.lang.String XML_PI_DATA
See Also:
Constant Field Values

XML_NAMESPACE

public static final java.lang.String XML_NAMESPACE
See Also:
Constant Field Values

XML_NAMESPACE_PREFIX_SEP

public static final java.lang.String XML_NAMESPACE_PREFIX_SEP
See Also:
Constant Field Values
Constructor Detail

XPagesDOMUtil

public XPagesDOMUtil()
Method Detail

addComplexProperty

public static org.w3c.dom.Element addComplexProperty(org.w3c.dom.Element elt,
                                                     java.lang.String propertyName,
                                                     java.lang.String value)
Adds a complex property to the given element. Certain tags support complex properties. This utility method will add complex properties to tags and ensure that the complex property is well formed. e.g.
 <xp:inputText id="inputText1">
  <xp:this.converter>
      <xp:convertDateTime type="date"></xp:convertDateTime>
  </xp:this.converter>
 </xp:inputText>
 

Parameters:
elt - the element to which the complex property is being defined
propertyName - the name of the complex property
value - the value of the complex property
Returns:
the complex property Element

checkParent

protected static boolean checkParent(FacesDefinition definition,
                                     java.lang.String namespaceUri,
                                     java.lang.String id)

clearElement

public static void clearElement(org.w3c.dom.Element element)
Remove all of the given element's children.

Parameters:
element - the element whose children are to be removed

clearIds

public static void clearIds(org.w3c.dom.Element element)
Set all the IDs in the given element and all it's children to null.

Parameters:
element - the element to clear

createChildElement

public static org.w3c.dom.Element createChildElement(org.w3c.dom.Element parent,
                                                     FacesRegistry registry,
                                                     java.lang.String tag)
Create a child control inside another element. Will create the this.facets element if it does not already exist.

Parameters:
parent - the parent of the element to be created
registry - The FacesRegistry for the current application
tag - the tag name of the new element
Returns:
the newly created element

createElement

public static org.w3c.dom.Element createElement(org.w3c.dom.Document ownerDocument,
                                                FacesRegistry registry,
                                                java.lang.String uri,
                                                java.lang.String tagName)
Helper method to create an element. Ensures the element has the correct tag prefix.

Parameters:
owenerDocument - the document where the element is to be created
registry - the FacesRegistry for the current application
uri - the URI for the new element
tagName - the XML tag local name of the new element
Returns:
the newly created Element

createNamespacePrefix

public static java.lang.String createNamespacePrefix(java.lang.String prefix)
Creates a namespace prefix, given the control prefix.

Parameters:
prefix - the proposed prefix, may not be null
Returns:
a string of the form "xmlns:prefix"

createQualifiedTagName

public static java.lang.String createQualifiedTagName(java.lang.String prefix,
                                                      java.lang.String localName)
Combine a prefix and local name into a qualified name.

Parameters:
prefix - the namespace prefix
localName - the XML localname of the tag.
Returns:
a qualified tag name

createXPagesElement

public static org.w3c.dom.Element createXPagesElement(org.w3c.dom.Document doc,
                                                      java.lang.String localName)
Creates an XPages core control element.

Parameters:
doc - document that is to contain the element, cannot be null;
localName - the XML local tag name of the element to be created, must belong to the XPages namespace
Returns:
an element that belongs to the core XPages namespace.

elementNeedsId

protected static boolean elementNeedsId(FacesRegistry registry,
                                        org.w3c.dom.Element element,
                                        org.w3c.dom.Document doc)
Determines if the given element requires an ID in accordance with the tag's definition in the FacesRegistry.

Parameters:
tagName -
Returns:
true if Id attribute is valid for this tag, otherwise false

elementNeedsVar

protected static boolean elementNeedsVar(FacesRegistry registry,
                                         org.w3c.dom.Element element,
                                         org.w3c.dom.Document doc)
Determines if the given element requires a var attribute in accordance with the tag's definition in the FacesRegistry.

Parameters:
tagName -
Returns:
true if var attribute is valid for this tag, otherwise false

ensureNamespaceDeclaration

public static java.lang.String ensureNamespaceDeclaration(org.w3c.dom.Document doc,
                                                          java.lang.String namespaceUri,
                                                          java.lang.String prefix)
Ensure a namspaceUri exists in a document. Add the namespace uri to the document if it does not exist.

Parameters:
doc - the document
namespaceUri - URI being sought
prefix - the prefix to use if one is not already defined
Returns:
the new prefix generated to resolve a conflict in the document. The node being added should be updated to have this prefix. If null, no change to the prefix

ensureRequiredNodesExist

public static boolean ensureRequiredNodesExist(org.w3c.dom.Document root)
Ensure the required document nodes exist to make this model a legal XPages form. If the required nodes exists, the model will not be modified. If the required nodes are missing, then they will be inserted.
The items tested for are: the XML processing instruction, the XPage "view" tag.
This is a helper method that calls ensureProcessingInstructionExists(Document) and ensureViewExists(Document).

Parameters:
root - the root of the dom document
Returns:
true if the required elements existed, false if some had to be added

ensureUniqueIds

public static void ensureUniqueIds(org.w3c.dom.Document doc,
                                   org.w3c.dom.Node root,
                                   FacesRegistry registry)
Ensures the ids applied to the supplied node are unique in the context of the document they are being inserted into.

Parameters:
doc - the Document that the root Node will be inserted into
root - the Node to be inserted into the Document.
registry - the FacesRegistry for the current application

ensureUniqueIds

public static void ensureUniqueIds(org.w3c.dom.Document doc,
                                   org.w3c.dom.Node root,
                                   FacesRegistry registry,
                                   boolean generateIdIfNotSet)
Ensures the ids applied to the supplied node are unique in the context of the document they are being inserted into. However if a tag does not have a preassigned ID and does not have an ID as a required attribute in the FacesRegistry then an ID will not be assigned. If the client always needs an id to be added regardless of it being a required attribute then it is advised to use

Parameters:
doc - the Document that the root Node will be inserted into
root - the Node to be inserted into the Document.
registry - the FacesRegistry for the current application
generateIdIfNotSet - if true, and a Node is found to not have an id an ID will be generated for the node

ensureUniqueIdsGenerateIfRequested

public static void ensureUniqueIdsGenerateIfRequested(org.w3c.dom.Document doc,
                                                      org.w3c.dom.Node root,
                                                      FacesRegistry registry,
                                                      boolean generateId)
Using the given document as a reference for existing ids, ensures every element in the root has a unique id. This method disregards whether or not the element requires an id, if generateId is true then it will always generate an ID for the given node (and its children).

Parameters:
doc - the document that the node is being inserted into
FacesRegistry - the registry for the current application
generateId - if true and an element doesn't have an id, then a new one will be set. If false an id is not generated

ensureUniqueVars

public static void ensureUniqueVars(org.w3c.dom.Document doc,
                                    org.w3c.dom.Node root,
                                    FacesRegistry registry)
Using the given document as a reference for existing vars, ensures every element in the given node has a unique var.

Parameters:
doc - the document that the node is being inserted into
root - the node being inserted - will be examined for the var attribute
registry - the FacesRegistry for the current application

findGlobalDefAndAddDependency

public static boolean findGlobalDefAndAddDependency(java.lang.String uri,
                                                    java.lang.String tagName,
                                                    DesignerProject project)
Finds a FacesDefinition for the given tag. If the FacesDefinition is not available in the current FacesRegistry as defined in the DesignerProject then it is determined that the current application does not have a dependency on the library that contains the particular tag in question.

Parameters:
uri - the namespace URI of the tag being added to the page
tagName - the tag name of the tag being added to the page
project - the current application
Returns:
true if the FacesDefinition was found.

formatNode

public static void formatNode(org.w3c.dom.Node node,
                              org.w3c.dom.ranges.Range range)
Formats a single node

Parameters:
node -
range -

formatNodes

public static void formatNodes(org.w3c.dom.Node[] nodes,
                               org.w3c.dom.ranges.Range range)
Format an array of nodes.

Parameters:
nodes -
range -

generateUniqueId

public static java.lang.String generateUniqueId(java.util.List<java.lang.String> idList,
                                                org.w3c.dom.Element element)
Returns a unique id candidate for the given element.

Parameters:
idList - a list of existing ids
element - the new element being added to the page
Returns:
a unique id based on the element's local name, plus a unique index

generateUniqueId

public static java.lang.String generateUniqueId(java.util.List<java.lang.String> idList,
                                                org.w3c.dom.Element element,
                                                java.lang.String hint)
Returns a unique id candidate for the given element.

Parameters:
idList - a list of existing ids
element - the new element being added to the page
hint - a hint that will be used in place of the tag name if provided
Returns:
a unique var based on the element's local name (or the hint if provided), plus a unique index

generateUniqueVar

public static java.lang.String generateUniqueVar(java.util.List<java.lang.String> varList,
                                                 org.w3c.dom.Element element)
Returns a unique var candidate for the given element.

Parameters:
varList - a list of existing vars
element - the new element being added to the page
Returns:
a unique var based on the element's local name, plus a unique index

generateUniqueVar

public static java.lang.String generateUniqueVar(java.util.List<java.lang.String> varList,
                                                 org.w3c.dom.Element element,
                                                 java.lang.String hint)
Returns a unique var candidate for the given element.

Parameters:
varList - a list of existing vars
element - the new element being added to the page
hint - a hint that will be used in place of the tag name if provided
Returns:
a unique var based on the element's local name (or the hint if provided), plus a unique index

getAttribute

public static java.lang.String getAttribute(org.w3c.dom.Element element,
                                            java.lang.String attribute)
Helper method to get an attribute value. This is required because in the XSP markup, some attributes can be defined as this.attribute in a child tag. e.g.
 <inputText id="inputText1">
     <xp:this.value><![CDATA[#{javascript:return "test"}]]></xp:this.value>
 </inputText>
 

Parameters:
elt - the element that whose attribute value is being queried
attributeName - the name of the attribute that is sought
Returns:
the value of the attribute, null if the attribute is not set

getAttributeChildren

public static java.util.Map<java.lang.String,java.lang.String> getAttributeChildren(org.w3c.dom.Element element)
Get all the "this." attribute children of a node. The attribute values are returned as a Map.

Parameters:
element - the element to be examined
Returns:
a map where each entry in the map is a attribute, value pair. The attribute is the this.attribute with the "this." stripped off.

getAttributeElement

public static org.w3c.dom.Element getAttributeElement(org.w3c.dom.Element element,
                                                      java.lang.String attribute)
Return the element for the given attribute if it exists. e.g.
     <xp:inputText>
           <xp:this.style>width:300px;</xp:this.style>
     </xp:inputText>
 
getAttributeElement( element, 'style") would return the element for <this.style>

Parameters:
element - the Element whose attribute is being queried
attribute - the name of the attribute we are looking up
Returns:
the element that is used to store the attribtue value, may be null

getAttributes

public static java.util.Map<java.lang.String,java.lang.String> getAttributes(org.w3c.dom.Element element)
Get all the attributes for an element. This includes both the attributes on the element and complex child attributes.

Parameters:
element - node to get attributes for. May not be null.
Returns:
all attributes of an element. The attribute name is the key and the attribute value is the value of each entry.

getDefaultPrefix

public static java.lang.String getDefaultPrefix()
Returns the default namespace prefix for an XPage Core tag.

Returns:
the default XSP core namespace prefix

getFacesDefinition

public static FacesDefinition getFacesDefinition(org.w3c.dom.Element element,
                                                 FacesRegistry registry)
Return a FacesDefintion for the given element.

Parameters:
element - the element whose definition is sought
registry - the FacesRegistry for the current applicatio
Returns:
the definition of the requested element, may be null

getIds

public static java.lang.String[] getIds(org.w3c.dom.Node root,
                                        org.w3c.dom.Node nodeToExclude)
Returns the IDs of all of the node that are a child of the given node. The caller can optionally choose to ignore a certain node in the hierarchy.

Parameters:
root - the node to search through.
Returns:
an array of strings containing the ids of the XPage components on the page

getIds

public static java.lang.String[] getIds(org.w3c.dom.Node startNode,
                                        org.w3c.dom.Node nodeToExclude,
                                        FacesRegistry registry,
                                        java.lang.String namespaceUri,
                                        java.lang.String id,
                                        boolean checkParent)
Returns an array of ids that are already defined on the XPage.

Parameters:
startNode - the node to start searching from
nodeToExclude - a particular node whose id should not be included in the returned array
registry - the FacesRegistry for the current application
namespaceUri - an optional namespace that can be used to filter the elements whose ids are checked
id - an optional control type id of controls to be filtered. e.g. controls of type "javax.faces.Output"
checkParent - a flag indicating whether or not the FacesDefinition hierarchy should be searched
Returns:
an array of IDs corresponding to the search criteria

getIdsExcludeList

public static java.lang.String[] getIdsExcludeList(org.w3c.dom.Node root,
                                                   java.util.List<org.w3c.dom.Node> nodesToExclude)
Parameters:
root -
nodesToExclude -
Returns:

getIdsExcludeList

public static java.lang.String[] getIdsExcludeList(org.w3c.dom.Node startNode,
                                                   java.util.List<org.w3c.dom.Node> nodesToExclude,
                                                   FacesRegistry registry,
                                                   java.lang.String namespaceUri,
                                                   java.lang.String id,
                                                   boolean checkParent)
Parameters:
id - return only ids of elements with the given ID and URI - pass null in to disregard this check.
checkParent - if looking for only the given namespace, tagname, if this element does not match, should we check to see if it inherits from this type of element?

getModeForValue

public static int getModeForValue(java.lang.String attributeValue)
Returns the 'mode' for a given attribute value. The mode will be one of

Parameters:
attributeValue - the value of an attribute
Returns:

getNamespacePrefix

public static java.lang.String getNamespacePrefix(org.w3c.dom.Document doc,
                                                  java.lang.String namespaceUri)
Get the namespace prefix in use in a document of a namespaceUri.

Parameters:
doc - the document to search for the prefix
namespaceUri - the namespace URI being searched for
Returns:
the namespace prefix, or null if the namespace uri is not declared in this document.

getNamespaceUri

public static java.lang.String getNamespaceUri()
Get the default namespace URI for core XPage controls

Returns:
the namespace uri of the XPage controls.

getNamespaceUri

public static java.lang.String getNamespaceUri(org.w3c.dom.Document doc,
                                               org.w3c.dom.Node node)
Return the namespace uri for the given element, searching the document if necessary.

Parameters:
doc - the document to search
node - the node whose URI is sought

getNamespaceUriForPrefix

public static java.lang.String getNamespaceUriForPrefix(org.w3c.dom.Document doc,
                                                        java.lang.String prefix)
Return the namespace uri associated with the given prefix, or null if there is none.

Parameters:
doc - the document to search
prefix - the prefix whose URI is sought

getPrefix

public static java.lang.String getPrefix(org.w3c.dom.Document doc,
                                         java.lang.String namespaceUri,
                                         FacesRegistry registry,
                                         java.lang.String tagName)
Return the prefix for the given namespace URI and tag name.

Parameters:
doc - the document to search
namespaceUri - the namespace URI whose prefix is sought
registry - the FacesRegistry which contains the tag definition
tagName - the tag that requires a prefix
Returns:
a prefix for the given tag

getRootTagName

public static java.lang.String getRootTagName()
Get the tagname that is the root of the xsp file (view).

Returns:
tagname without the prefix.

getValuesOfAttr

public static java.lang.String[] getValuesOfAttr(org.w3c.dom.Node root,
                                                 org.w3c.dom.Node nodeToExclude,
                                                 FacesRegistry registry,
                                                 java.lang.String namespaceUri,
                                                 java.lang.String id,
                                                 boolean checkParent,
                                                 java.lang.String attrName)
Returns the values for all occurrances of a given attribute on a given document

Parameters:
root - the root node to start searching from
nodeToExclude - a node to exclude from the search
registry - the FacesRegistry for the current application
namespaceUri - the URI for nodes to check
id - an optional control type id of controls to be filtered. e.g. controls of type "javax.faces.Output"
checkParent - a flag which determines if only children of the root should be searched
attrName - the name of the attribute whose values are to be returned
Returns:
an array of attribute values

getValuesOfAttrExcludeList

public static java.lang.String[] getValuesOfAttrExcludeList(org.w3c.dom.Node root,
                                                            java.util.List<org.w3c.dom.Node> nodesToExclude,
                                                            FacesRegistry registry,
                                                            java.lang.String namespaceUri,
                                                            java.lang.String id,
                                                            boolean checkParent,
                                                            java.lang.String attrName)
Returns the values for all occurrances of a given attribute on a given document

Parameters:
root - the root node to start searching from
nodesToExclude - a list of nodes to exclude from the search
registry - the FacesRegistry for the current application
namespaceUri - the URI for nodes to check
id - an optional control type id of controls to be filtered. e.g. controls of type "javax.faces.Output"
checkParent - a flag which determines if only children of the root should be searched
attrName - the name of the attribute whose values are to be returned
Returns:
an array of attribute values

getVars

public static java.lang.String[] getVars(org.w3c.dom.Node startNode,
                                         org.w3c.dom.Node nodeToExclude)
Returns all of the values of the 'var' attributes on the document

Parameters:
startNode - the starting point for the search
nodeToExclue - a node to exclude from the search
Returns:
an array containing all of the values of the var attribute on the page

getVars

public static java.lang.String[] getVars(org.w3c.dom.Node startNode,
                                         org.w3c.dom.Node nodeToExclude,
                                         FacesRegistry registry,
                                         java.lang.String namespaceUri,
                                         java.lang.String id,
                                         boolean checkParent)
Returns the values of all of the var attributes on the given document.

Parameters:
startNode - the node to start searching from
nodeToExclude - a node that should not be included in the search
registry - the FacesRegistry for the current application
namespaceUri - the URI of the tags that are to be searched
id - an optional control type id of controls to be filtered. e.g. controls of type "javax.faces.Output"
checkParent - a flag which determines if only children of the root should be searched
Returns:
an array of values of the var attributes encountered in the search

getViewNode

public static org.w3c.dom.Element getViewNode(org.w3c.dom.Document doc)
Get the view node of a given document.

Parameters:
doc - the document to search
Returns:
the 'view' node that is the root of any XPage

initializeDefaultValues

public static void initializeDefaultValues(org.w3c.dom.Element element,
                                           FacesRegistry registry)
Helper method to call after an element has been created. Sets default values in the element.

Parameters:
element - the element whose attributes are to be initialized
registry - the FacesRegistry that contains a definition for the given element

isComponent

public static boolean isComponent(FacesDefinition def,
                                  java.lang.String namespaceUri,
                                  java.lang.String id)
Return true if the given def matches the given uri and id.


setAttribute

public static boolean setAttribute(org.w3c.dom.Element elt,
                                   java.lang.String attributeName,
                                   java.lang.String value)
Helper method to set an attribute. This is required because in the XSP markup, some attributes can be defined as this.attribute in a child tag. e.g.
 <inputText id="inputText1">
     <xp:this.value><![CDATA[#{javascript:return "test"}]]></xp:this.value>
 </inputText>
 

Parameters:
elt - the element that the attribute is to be set on
attributeName - the name of the attribute that is to be set
value - the new value of the attribute