Class Index | File Index

Classes


Class myfaces._impl._util._Dom


Extends myfaces._impl.core._Runtime.

Defined in: _Dom.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Object singleton collection of dom helper routines (which in later incarnations will get browser specific speed optimizations) Since we have to be as tight as possible we will focus with our dom routines to only the parts which our impl uses.
Method Summary
Method Attributes Method Name and Description
 
break the standard events from an existing dom node (note this method is not yet used, but can be used by framework authors to get rid of ie circular event references) another way probably would be to check all attributes of a node for a function and if one is present break it by nulling it I have to do some further investigation on this.
 
byIdOrName(elem)
determines to fetch a node from its id or name, the name case only works if the element is unique in its name
 
concatenation routine which concats all childnodes of a node which contains a set of CDATA blocks to one big string
 
standard constructor
 
deleteItem(itemIdToReplace)
Simple delete on an existing item
 
detach(items)
detchaes a set of nodes from their parent elements in a browser independend manner
 
findAll(rootNode, filter, deepScan)
a filtered findAll for subdom treewalking (which uses browser optimizations wherever possible)
 
findByTagName(fragment, tagName, deepScan)
determines the number of nodes according to their tagType
 
findByTagNames(fragment, tagNames, deepScan)
optimized search for an array of tag names
 
fuzzy form detection which tries to determine the form an item has been detached.
 
getAttribute(node, attr)
cross ported from dojo fetches an attribute from a node
 
getChild(item, childName, itemName)
gets the child of an item with a given tag name
 
getClass(node)
fetches the style class for the node cross ported from the dojo toolkit
 
getClasses(node)
fetches the class for the node, cross ported from the dojo toolkit
 
getFilteredChild(item, filter)
a closure based child filtering routine which steps one level down the tree and applies the filter closure
 
getFilteredParent(item, filter)
A parent walker which uses a filter closure for filtering
 
getParent(item, tagName)
gets a parent of an item with a given tagname
 
fetches the window id for the current request note, this is a preparation method for jsf 2.2
 
hasAttribute(node, attr)
checks whether the given node has an attribute attached
 
Checks whether the browser is dom compliant.
 
node id or name, determines the valid form identifier of a node depending on its uniqueness Usually the id is chosen for an elem, but if the id does not exist we try a name fallback.
 
outerHTML(item, markup)
outerHTML replacement which works cross browserlike but still is speed optimized
 
replaceElement(item, evalNodes)
for performance reasons we work with replaceElement and replaceElements here after measuring performance it has shown that passing down an array instead of a single node makes replaceElement twice as slow, however a single node case is the 95% case
 
replaceElements(item, evalNodes)
replaces an element with another element or a set of elements
 
runScripts(item, xmlData)
Run through the given Html item and execute the inline scripts (IE doesn't do this by itself)
 
setAttribute(node, attr, val)
bugfixing for ie6 which does not cope properly with setAttribute
Class Detail
myfaces._impl._util._Dom()
Object singleton collection of dom helper routines (which in later incarnations will get browser specific speed optimizations) Since we have to be as tight as possible we will focus with our dom routines to only the parts which our impl uses. A jquery like query API would be nice but this would blow up our codebase significantly
Method Detail
breakEvents(node)
break the standard events from an existing dom node (note this method is not yet used, but can be used by framework authors to get rid of ie circular event references) another way probably would be to check all attributes of a node for a function and if one is present break it by nulling it I have to do some further investigation on this. The final fix is to move away from ie6 at all which is the root cause of this.
Parameters:
node
the node which has to be broken off its events

byIdOrName(elem)
determines to fetch a node from its id or name, the name case only works if the element is unique in its name
Parameters:
{String} elem

concatCDATABlocks(node)
concatenation routine which concats all childnodes of a node which contains a set of CDATA blocks to one big string
Parameters:
{Node} node
the node to concat its blocks for

constructor_()
standard constructor

deleteItem(itemIdToReplace)
Simple delete on an existing item
Parameters:
itemIdToReplace

{Array} detach(items)
detchaes a set of nodes from their parent elements in a browser independend manner
Parameters:
{Nodelist} items
the items which need to be detached
Returns:
{Array} an array of nodes with the detached dom nodes

findAll(rootNode, filter, deepScan)
a filtered findAll for subdom treewalking (which uses browser optimizations wherever possible)
Parameters:
{|Node|} rootNode
the rootNode so start the scan
filter
filter closure with the syntax {boolean} filter({Node} node)
deepScan
if set to true or not set at all a deep scan is performed (for form scans it does not make much sense to deeply scan)

findByTagName(fragment, tagName, deepScan)
determines the number of nodes according to their tagType
Parameters:
{Node} fragment
(Node or fragment) the fragment to be investigated
{String} tagName
the tag name (lowercase)
{Boolean} deepScan
if set to true a found element does not prevent to scan deeper (the normal usecase is false, which means if the element is found only its adjacent elements will be scanned, due to the recursive descension this should work out with elements with different nesting depths but not being parent and child to each other
Returns:
the child elements as array or null if nothing is found

findByTagNames(fragment, tagNames, deepScan)
optimized search for an array of tag names
Parameters:
fragment
the fragment which should be searched for
tagNames
an map indx of tag names which have to be found
deepScan
if set to true a deep scan is performed otherwise a shallow scan

fuzzyFormDetection(elem)
fuzzy form detection which tries to determine the form an item has been detached. The problem is some Javascript libraries simply try to detach controls by reusing the names of the detached input controls. Most of the times, the name is unique in a jsf scenario, due to the inherent form mapping. One way or the other, we will try to fix that by identifying the proper form over the name We do it in several ways, in case of no form null is returned in case of multiple forms we check all elements with a given name (which we determine out of a name or id of the detached element) and then iterate over them to find whether they are in a form or not. If only one element within a form and a given identifier found then we can pull out and move on We cannot do much further because in case of two identical named elements all checks must fail and the first elements form is served. Note, this method is only triggered in case of the issuer or an ajax request is a detached element, otherwise already existing code has served the correct form. This method was added because of https://issues.apache.org/jira/browse/MYFACES-2599 to support the integration of existing ajax libraries which do heavy dom manipulation on the controls side (Dojos Dijit library for instance).
Parameters:
{Node} elem
- element as source, can be detached, undefined or null
Returns:
either null or a form node if it could be determined

getAttribute(node, attr)
cross ported from dojo fetches an attribute from a node
Parameters:
{String} node
the node
{String} attr
the attribute
Returns:
the attributes value or null

getChild(item, childName, itemName)
gets the child of an item with a given tag name
Parameters:
{Node} item
- parent element
{String} childName
- TagName of child element
{String} itemName
- name attribute the child can have (can be null)

getClass(node)
fetches the style class for the node cross ported from the dojo toolkit
Parameters:
{String|Object} node
the node to search
Returns:
the className or ""

getClasses(node)
fetches the class for the node, cross ported from the dojo toolkit
Parameters:
{String|Object} node
the node to search

getFilteredChild(item, filter)
a closure based child filtering routine which steps one level down the tree and applies the filter closure
Parameters:
item
the node which has to be investigates
filter
the filter closure

getFilteredParent(item, filter)
A parent walker which uses a filter closure for filtering
Parameters:
{Node} item
the root item to ascend from
{function} filter
the filter closure

getParent(item, tagName)
gets a parent of an item with a given tagname
Parameters:
{Node} item
- child element
{String} tagName
- TagName of parent element

getWindowId()
fetches the window id for the current request note, this is a preparation method for jsf 2.2

hasAttribute(node, attr)
checks whether the given node has an attribute attached
Parameters:
{String|Object} node
the node to search for
{String} attr
the attribute to search for

isDomCompliant()
Checks whether the browser is dom compliant. Dom compliant means that it performs the basic dom operations safely without leaking and also is able to perform a native setAttribute operation without freaking out Not dom compliant browsers are all microsoft browsers in quirks mode and ie6 and ie7 to some degree in standards mode and pretty much every browser who cannot create ranges (older mobile browsers etc...) We dont do a full browser detection here because it probably is safer to test for existing features to make an assumption about the browsers capabilities

nodeIdOrName(elem)
node id or name, determines the valid form identifier of a node depending on its uniqueness Usually the id is chosen for an elem, but if the id does not exist we try a name fallback. If the passed element has a unique name we can use that one as subsequent identifier.
Parameters:
{String} elem

outerHTML(item, markup)
outerHTML replacement which works cross browserlike but still is speed optimized
Parameters:
item
the item to be replaced
markup
the markup for the replacement

replaceElement(item, evalNodes)
for performance reasons we work with replaceElement and replaceElements here after measuring performance it has shown that passing down an array instead of a single node makes replaceElement twice as slow, however a single node case is the 95% case
Parameters:
item
evalNodes

replaceElements(item, evalNodes)
replaces an element with another element or a set of elements
Parameters:
item
the item to be replaced
evalNodes
the elements

runScripts(item, xmlData)
Run through the given Html item and execute the inline scripts (IE doesn't do this by itself)
Parameters:
{Node} item
xmlData

setAttribute(node, attr, val)
bugfixing for ie6 which does not cope properly with setAttribute
Parameters:
node
attr
val

Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 06 2011 21:09:21 GMT-0500 (COT)