Class Index | File Index

Classes


Class adf.Utils

adf.Utils
Defined in: core.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
A collection of static utility functions and application properties, including information about the client browser name and version.
Field Summary
Field Attributes Field Name and Description
<static>  
adf.Utils.doPostBack
Determines how adf.Utils.submitForm behaves, when set to true, AJAX request will be sent, when false, traditional form submission will be used.
<static>  
adf.Utils.graphicsType
String name of graphics type supported by browser.
<static>  
adf.Utils.isFF15
<static>  
adf.Utils.isIE
<static>  
adf.Utils.isIE6
<static>  
adf.Utils.isIE7
<static>  
adf.Utils.isNav
<static>  
adf.Utils.KEY_DOWN
Down Cursor Code
<static>  
adf.Utils.KEY_ENTER
Enter Cursor Code
<static>  
adf.Utils.KEY_ESCAPE
Escape Key Code
<static>  
adf.Utils.KEY_LEFT
Left Cursor Code
<static>  
adf.Utils.KEY_RIGHT
Right Cursor Code
<static>  
adf.Utils.KEY_UP
Up Cursor Code
<static>  
adf.Utils.leftButton
Left Mouse Button Code
<static>  
adf.Utils.navType
<static>  
adf.Utils.rightButton
Right Mouse Button Code
<static>  
adf.Utils.userAgent
Method Summary
Method Attributes Method Name and Description
<static>  
adf.Utils.addEventListener(object, event, handler, context)
Attaches an event handler to the given objects event.
<static>  
adf.Utils.addFormElement(formId, name, value)
Creates an HTML hidden form input field to the form specified by its id.
<static>  
adf.Utils.buildRequestParams(formId)
Creates an HTTP request query string of key/value pairs by using form elements created with adf.Utils.addFormElement
<static>  
adf.Utils.buildRequestParamsFromObject(params)
Creates an HTTP request query string of key/value pairs with properties of an object literal that are not of the type "function".
<static>  
adf.Utils.cloneElementStyle(sourceElement, targetElement)
Clones the style properties of the source element and applies the values onto the target element
<static>  
adf.Utils.createGraphicsElement(id, cont)
If user client is Internet Explorer, creates an instance of adf.graphics.VmlElement, for Mozilla browsers creates an instance of adf.graphics.SvgElement.
<static>  
adf.Utils.createImage(src, width, height)
Convenience function used to create an HTML image element.
<static>  
adf.Utils.createXmlHttpObject()
Creats the object to submit AJAX request with.
<static>  
adf.Utils.endsWith(str, check)
Checks to see if a given string ends with a certain string.
<static>  
adf.Utils.fromHex(h)
Converts a hexadecimal value into its decimal number
<static>  
adf.Utils.getCheckBoxStates(root)
<static>  
adf.Utils.getElementBorders(element)
Returns the top, right, bottom, left borders height values in pixels of the given element in the form of an object literal
<static>  
adf.Utils.getElementBounds(element)
Returns the CSS style properties in the form of an adf.Rectangle for a given elements left, top, width and height values.
<static>  
adf.Utils.getElementPageBounds(element)
Uses dojo.coords() to determine the x and y position along with the height and width of the given element.
<static>  
adf.Utils.getElementsByClassName(element, className)
Retrieves all elements with the attribute "class" which has a value of the parameter className and is a descendant of the parameter element.
<static>  
adf.Utils.getErrorFromDocument(xml)
Checks an XML document for presence of an "error" tag element.
<static>  
adf.Utils.getEventSource(e)
Returns the target element of the event.
<static>  
adf.Utils.getFunctionByName(functionName, contexst)
Returns a reference to a function if it exists within the given context.
<static>  
adf.Utils.getJSessionId()
Retrieves the "JSESSIONID" value for the current session
<static>  
adf.Utils.getKeyCode(e)
Returns the key code associated with a keyboard event.
<static>  
adf.Utils.getMouseButton(e)
Returns the identifier for the button pressed to initiate the passed event
<static>  
adf.Utils.getPageBounds()
Returns the dimensions of the visible document area in the form of an adf.Rectanlge.
<static>  
adf.Utils.getServerUrl(formId)
Creates the URL to send form submissions to within the JSF application.
<static>  
adf.Utils.getStyleByClassName(name)
Returns the CSS properties currently available for the given style selector class name
<static>  
adf.Utils.getStyleValue(s)
Parses the integer value from the following types of CSS style values: 100px, %100 and returns the numeric portion.
<static>  
adf.Utils.getXmlDocument(xmlHttpResponse)
Returns an XML response document found within a given XmlHttp response object.
<static>  
adf.Utils.getXmlText(node)
Returns the text node value from an XML node.
<static>  
adf.Utils.getXY(e)
Returns the click point of an event object in the form of an adf.Point.
<static>  
adf.Utils.hideElement(element)
Hides an element by setting its CSS display property to "none".
<static>  
adf.Utils.indexOf(arr, item)
Duplicates the functionality of Array.indexOf() found in JavaScript 1.6
<static>  
adf.Utils.inheritsFrom(dest, source)
Copies functions and properties from one object to another to mimic object oriented inheritance.
<static>  
adf.Utils.isLeftButton(e)
Returns true if the passed event object was initiated by pressing the left mouse button, otherwise returns false.
<static>  
adf.Utils.moveElement(element, left, top)
Moves an element by modifying its CSS left and top properties
<static>  
adf.Utils.onHandleImage(img, src)
<static>  
adf.Utils.removeElement(element)
Removes the element from the DOM
<static>  
adf.Utils.removeElementStyle(element, css)
Sets the in-line style for each of the style properties found in the CSS to "" (empty string) for the given element
<static>  
adf.Utils.removeEventListener(eventId)
Removes an existing event handler that was added using adf.Utils.addEventListener.
<static>  
adf.Utils.removeFormElement(formId, name)
Removes a form input element that was added by using adf.Utils.addFormElement
<static>  
adf.Utils.sendAdfAjaxRequest(formId, params, includeFormContent, doGet, contentType)
Convenience function used for sending ADF lifecycle aware AJAX requests.
<static>  
adf.Utils.sendAjaxRequest(url, params, doGet, callback, contentType)
Convenience function used for sending any arbitray AJAX request.
<static>  
adf.Utils.setCheckBoxStates(root, chks)
<static>  
adf.Utils.setElementOpacity(element, opacity)
Sets opacity for the given element, regarless of browser specific implementation.
<static>  
adf.Utils.setElementStyle(element, css)
Applies the passed CSS property string to the passed element's (or id of the element) in-line style property.
<static>  
adf.Utils.setImageSrc(img, src)
Convenience function to update a given image element's src attribute.
<static>  
adf.Utils.showElement(element)
Shows an element by setting its CSS display property to "block"
<static>  
adf.Utils.stopEvent(e)
Stops event propogation in non-IE browsers, cancels bubbling in IE browsers.
<static>  
adf.Utils.stringToXml(xmlString)
Creates an XML object from a xml formated string.
<static>  
adf.Utils.submitForm(formId, async, callback, params)
Submits an HTTP request either in the form of a traditional form submission or by way of an AJAX request (if boolean value adf.Utils.doPostback is set to true)
<static>  
adf.Utils.toggleElement(element)
Toggles an elements display property between "none" and "block"
<static>  
adf.Utils.toHex(n)
Converts a decimal number into it hexadecimal value
<static>  
adf.Utils.toMapPoint(extent, width, height, point)
Converts a screen coordinate point into a map coordinate point with the help of an extent object and viewport dimensions of a the map
<static>  
adf.Utils.toScreenPoint(extent, width, height, point)
Converts a map coordinate point into a screen coordinate point with the help of an extent object and viewport dimensions of a the map
<static>  
adf.Utils.trim(str)
Duplicates the functionality of String.trim() found in JavaScript 1.8.1
Class Detail
adf.Utils()
A collection of static utility functions and application properties, including information about the client browser name and version. Utility functions inclue AJAX request senders, CSS property modifiers and an event handling framework.
Field Detail
<static> {Boolean} adf.Utils.doPostBack
Determines how adf.Utils.submitForm behaves, when set to true, AJAX request will be sent, when false, traditional form submission will be used.
Default Value:
true

<static> {String} adf.Utils.graphicsType
String name of graphics type supported by browser. (if IE, then "VML", else "SVG")

<static> adf.Utils.isFF15
Deprecated:
use adf.isFF instead

<static> adf.Utils.isIE
Deprecated:
use adf.isIE instead

<static> adf.Utils.isIE6
Deprecated:
use adf.isIE instead

<static> adf.Utils.isIE7
Deprecated:
use adf.isIE instead

<static> adf.Utils.isNav

<static> {Number} adf.Utils.KEY_DOWN
Down Cursor Code
Default Value:
40

<static> {Number} adf.Utils.KEY_ENTER
Enter Cursor Code
Default Value:
13

<static> {Number} adf.Utils.KEY_ESCAPE
Escape Key Code
Default Value:
27

<static> {Number} adf.Utils.KEY_LEFT
Left Cursor Code
Default Value:
37

<static> {Number} adf.Utils.KEY_RIGHT
Right Cursor Code
Default Value:
39

<static> {Number} adf.Utils.KEY_UP
Up Cursor Code
Default Value:
38

<static> {Number} adf.Utils.leftButton
Left Mouse Button Code
Default Value:
1

<static> adf.Utils.navType
Deprecated:
use adf.isIE, adf.isFF, etc...

<static> {Number} adf.Utils.rightButton
Right Mouse Button Code
Default Value:
2

<static> adf.Utils.userAgent
Method Detail
<static> adf.Utils.addEventListener(object, event, handler, context)
Attaches an event handler to the given objects event.
Parameters:
object
{Object} The object to listen for an event on
event
{String} The name of the event to handle
handler
{Function} The handler function
context
{Object} The context to execute the handler function within. If left undefined, the function will execute in the global scope.
Deprecated:
use adfdojo.connect() instead.
Returns:
A unique identifier of this event handler to be used with when removing the event handler with adf.Utils.removeEventListener

<static> adf.Utils.addFormElement(formId, name, value)
Creates an HTML hidden form input field to the form specified by its id. The name and value parameters are applied to the input elements respective attributes
Parameters:
formId
{String} id attribute value of the form you wish to add an input element to
{String} name
attribute content for new input element
{String} value
attribute content for new input element

<static> {String} adf.Utils.buildRequestParams(formId)
Creates an HTTP request query string of key/value pairs by using form elements created with adf.Utils.addFormElement
Parameters:
formId
{String} The form id you wish to uses field values from to build a query string
Returns:
{String} request query string

<static> {String} adf.Utils.buildRequestParamsFromObject(params)
Creates an HTTP request query string of key/value pairs with properties of an object literal that are not of the type "function".
Parameters:
params
{Object} an object literal containing the properties to serialize into a string
Returns:
{String} request query string

<static> adf.Utils.cloneElementStyle(sourceElement, targetElement)
Clones the style properties of the source element and applies the values onto the target element
Parameters:
{HTMLElement} sourceElement
{Element} The element to clone CSS properties and values from
{HTMLElement} targetElement
{Element} The element to apply cloned CSS information to

<static> adf.Utils.createGraphicsElement(id, cont)
If user client is Internet Explorer, creates an instance of adf.graphics.VmlElement, for Mozilla browsers creates an instance of adf.graphics.SvgElement.
Parameters:
id
{String} the id to give the newly created element
cont
{Element} this element to add this new graphics element to
Returns:
An instance of adf.graphics.Element

<static> adf.Utils.createImage(src, width, height)
Convenience function used to create an HTML image element. When used in IE6 browsers, this function will automatically apply the AlphaImageLoader filter on PNG images to properly display transparent pixels.
Parameters:
src
{String} The path to the image source
width
{Integer} The width of the image in pixels
height
{Integer} The height of the image in pixels
Returns:
A reference to the image element created

<static> adf.Utils.createXmlHttpObject()
Creats the object to submit AJAX request with. This funciton checks for the clients browser and returns the browser specific XMLHTTP object.

<static> adf.Utils.endsWith(str, check)
Checks to see if a given string ends with a certain string.
  
    adf.Utils.endsWith("test", "est") returns true
    adf.Utils.endsWith("test", "ts") returns false
  
Parameters:
str
check

<static> adf.Utils.fromHex(h)
Converts a hexadecimal value into its decimal number
Parameters:
h
{Number} A hexadecimal value

<static> adf.Utils.getCheckBoxStates(root)
Parameters:
root

<static> adf.Utils.getElementBorders(element)
Returns the top, right, bottom, left borders height values in pixels of the given element in the form of an object literal
Parameters:
{Element} element
{Element} The HTML element to get CSS border width values for

<static> adf.Utils.getElementBounds(element)
Returns the CSS style properties in the form of an adf.Rectangle for a given elements left, top, width and height values.
Parameters:
{Element} element
{Element} The HTML element to get bounds information for

<static> adf.Utils.getElementPageBounds(element)
Uses dojo.coords() to determine the x and y position along with the height and width of the given element. Values are returned in the form of an adf.Rectangle.
Parameters:
{Element} element
{Element} The HTML element to get page bounds for

<static> adf.Utils.getElementsByClassName(element, className)
Retrieves all elements with the attribute "class" which has a value of the parameter className and is a descendant of the parameter element.
Parameters:
element
{Element} the HTML element to search for element within
className
{String} the CSS class name to retrieve elements by
Deprecated:
use adfdojo.query(".className", element) instead

<static> adf.Utils.getErrorFromDocument(xml)
Checks an XML document for presence of an "error" tag element. The string contained within the error tag is returned unless it contains the string "redirect=", which then it modifies the window.location.href property to redirect to that page.
Parameters:
xml
{XMLDocument} The xml document object to read

<static> adf.Utils.getEventSource(e)
Returns the target element of the event.
Parameters:
{Event} e
{Event}

<static> adf.Utils.getFunctionByName(functionName, contexst)
Returns a reference to a function if it exists within the given context. This function is very helpful in avoiding eval() calls when you need to instantiate an object based on a string input.
  
    var constructorReference = adf.Utils.getFunctionByName("adf.Point", window);
    var myPoint = new constructorReference(100, 40);
  
Parameters:
functionName
{String} the name of the function you want a reference to
contexst
{Object} the context or scope you want to retreive the function reference in
Returns:
a reference tot he named function if it exists, null otherwise

<static> adf.Utils.getJSessionId()
Retrieves the "JSESSIONID" value for the current session

<static> adf.Utils.getKeyCode(e)
Returns the key code associated with a keyboard event. For events handled using adfdojo.connect(), you can alternatively use keycodes provided by the Dojo Toolkit in adf.keys.
Parameters:
{Event} e
{Event}

<static> adf.Utils.getMouseButton(e)
Returns the identifier for the button pressed to initiate the passed event
Parameters:
{Event} e
{Event}

<static> adf.Utils.getPageBounds()
Returns the dimensions of the visible document area in the form of an adf.Rectanlge. Values for top and left are always zero (0).

<static> adf.Utils.getServerUrl(formId)
Creates the URL to send form submissions to within the JSF application. Since the JSF framework is based on an HTML form element, the URL is dependent upon a single form id.
Parameters:
formId
{String} id of the form you wish to get the server URL for

<static> adf.Utils.getStyleByClassName(name)
Returns the CSS properties currently available for the given style selector class name
Parameters:
{String} name
{String} The class selector label
Returns:
the string representation of the style properties associated with the given CSS class name

<static> adf.Utils.getStyleValue(s)
Parses the integer value from the following types of CSS style values: 100px, %100 and returns the numeric portion.
Parameters:
s

<static> adf.Utils.getXmlDocument(xmlHttpResponse)
Returns an XML response document found within a given XmlHttp response object.
Parameters:
xmlHttpResponse
{Object} The XmlHttpResponse object

<static> adf.Utils.getXmlText(node)
Returns the text node value from an XML node.
  a reference to the following node: "text value" would yield "text value"
Parameters:
node
{Element} An Element object

<static> adf.Utils.getXY(e)
Returns the click point of an event object in the form of an adf.Point. Both x and y values for this point are relative to the top/left most point visible within the document.
Parameters:
{Event} e
{Event}

<static> adf.Utils.hideElement(element)
Hides an element by setting its CSS display property to "none".
Parameters:
{Element | String} element
{Element | String} the element or id of the element to hide

<static> adf.Utils.indexOf(arr, item)
Duplicates the functionality of Array.indexOf() found in JavaScript 1.6
Parameters:
arr
item
Deprecated:
use adf.indexOf() instead

<static> adf.Utils.inheritsFrom(dest, source)
Copies functions and properties from one object to another to mimic object oriented inheritance. If any names of properties or functions are the same in both objects, the destination object retains its orignal contents. Use adfdojo.mixin() as an alternative for copying functions and properties or adfdojo.declare() for sub-classing.
adf.Utils.inheritsFrom(this, someOtherObject);
Parameters:
dest
{Object} The object to copy functions and properties to
source
{Object} The object to copy functions and properties from
Returns:
The destination object with all functions and properties copied from the source

<static> adf.Utils.isLeftButton(e)
Returns true if the passed event object was initiated by pressing the left mouse button, otherwise returns false.
Parameters:
{Event} e
{Event}

<static> adf.Utils.moveElement(element, left, top)
Moves an element by modifying its CSS left and top properties
Parameters:
{Element} element
{Element | String} either an HTML element or its id (a string)
{Number} left
{Integer} value for the CSS left property
{Number} top
{Integer} value for the CSS top property

<static> adf.Utils.onHandleImage(img, src)
Parameters:
img
src

<static> adf.Utils.removeElement(element)
Removes the element from the DOM
Parameters:
element
{Element} The element to remove from the DOM
Deprecated:
use adf.destroy(element) instead

<static> adf.Utils.removeElementStyle(element, css)
Sets the in-line style for each of the style properties found in the CSS to "" (empty string) for the given element
Parameters:
element
{Element | String} the element (or id of the element) to remove in-line style properties for
css
{Strring} the CSS in-line style string containing properties you wish to remove from the given element

<static> adf.Utils.removeEventListener(eventId)
Removes an existing event handler that was added using adf.Utils.addEventListener.
Parameters:
eventId
{String} the unique id of the event you wish to remove the handler for
Deprecated:
use adfdojo.disconnect() instead

<static> adf.Utils.removeFormElement(formId, name)
Removes a form input element that was added by using adf.Utils.addFormElement
Parameters:
formId
{String} id attribute value of the form you wish to remove the specifiedinput element frm
{String} name
attribute value of the input element to remove

<static> adf.Utils.sendAdfAjaxRequest(formId, params, includeFormContent, doGet, contentType)
Convenience function used for sending ADF lifecycle aware AJAX requests. All requests sent through this function will have their responses handled by adf.Controls.processPostBack.
Parameters:
{String} formId
{String} The id of the form to submit data from
{Object} params
{Object} An object literal containing property names and values to be sent as request parameters
{Boolean} includeFormContent
{Boolean} When set to true, input elements added to the form with adf.Utils.addFormElement
{Boolean} doGet
{Boolean} When set to true, request will be sent via HTTP GET method, otherwise POST method
{String} contentType
{Boolean} forces the response to be handled with the provided HTTP content-type definition

<static> adf.Utils.sendAjaxRequest(url, params, doGet, callback, contentType)
Convenience function used for sending any arbitray AJAX request. You must provide a valid URL to send the request to. All request sent by this funciton call will have default handlers for error or timeouts. The default content-type header is set to "application/x-www-form-urlencoded" and the default HTTP method is "POST".
Parameters:
{String} url
{String} The request URL
{Object | String} params
{Object|String} This parameter is either an object literal containing the request parameters or a standard HTTP query string
{Boolean} doGet
{Boolean} Set this value to true if you would like to send the request as an HTTP GET, if false, request will be sent as an HTTP POST
{function} callback
{function} callback Function to call when response is returned. This callback function is called with the following parameters for convenience: request object, response object, original request parameters
{String} contentType
{String} Sets the content-type header value for posts
Returns:
dojo.Deferred Deferred Object for adding callbacks.

<static> adf.Utils.setCheckBoxStates(root, chks)
Parameters:
root
chks

<static> adf.Utils.setElementOpacity(element, opacity)
Sets opacity for the given element, regarless of browser specific implementation. Alternatively you can use the Dojo Toolkit provided function in adfdojo namespace, adfdojo.style(element, 0.5) to set opacity on an element.
Parameters:
element
{Element | String} The element, or id of the element, you wish to change opacity for
opacity
{Number} The value to set the opacity to, from 0 to 1 (including decimals) where 0 is completely transparent and 1 is fully opaque

<static> adf.Utils.setElementStyle(element, css)
Applies the passed CSS property string to the passed element's (or id of the element) in-line style property. Alternatively, use the built-in Dojo Toolkit function found in the adf namespace, adfdojo.style().
Parameters:
element
{Element | String} Either the element, or the id of the element you want to modify CSS properties for
css
{String} The CSS in-line string you wish to apply to the passed element.

<static> adf.Utils.setImageSrc(img, src)
Convenience function to update a given image element's src attribute. When used in IE6 browsers, this function will automatically apply the AlphaImageLoader filter on PNG images to properly display transparent pixels.
Parameters:
img
{Element} The image element to update
src
{String} The path to the image source

<static> adf.Utils.showElement(element)
Shows an element by setting its CSS display property to "block"
Parameters:
{Element | String} element
{Element | String} the element or id of the element to show

<static> adf.Utils.stopEvent(e)
Stops event propogation in non-IE browsers, cancels bubbling in IE browsers. When using adfdojo.connect() to handle events, events will all be normalized using the Dojo Toolkit and you can alternatively use adf.stopEvent(e).
Parameters:
{Event} e
{Event}

<static> adf.Utils.stringToXml(xmlString)
Creates an XML object from a xml formated string. Utilizes the "Microsoft.XMLDOM" object for IE browsers and DOMParser for Mozilla browsers.
Parameters:
xmlString
{String} a string containing xml content

<static> adf.Utils.submitForm(formId, async, callback, params)
Submits an HTTP request either in the form of a traditional form submission or by way of an AJAX request (if boolean value adf.Utils.doPostback is set to true)
Parameters:
formId
{String} The id of the form whos values you want to submit to server
async
{boolean} Forces an asyncronous (AJAX) call when set to true
callback
{function} The function to call when the asyncronous response is receieved. Ignored if adf.Utils.doPostBack or async is false
params
{Object} Parameters to send with the asyncrounous call. Ignored if adf.Utils.doPostBack or async is false

<static> adf.Utils.toggleElement(element)
Toggles an elements display property between "none" and "block"
Parameters:
{Element} element
{Element} the element to toggle display for

<static> adf.Utils.toHex(n)
Converts a decimal number into it hexadecimal value
Parameters:
n
{Number} A decimal value

<static> adf.Utils.toMapPoint(extent, width, height, point)
Converts a screen coordinate point into a map coordinate point with the help of an extent object and viewport dimensions of a the map
Parameters:
extent
{adf.Extent} The current extent of the {@adf.Map} object
width
{Integer} The width of the map
height
{Integer} The height of the map
point
{adf.Point} The screen coordinate point to convert

<static> adf.Utils.toScreenPoint(extent, width, height, point)
Converts a map coordinate point into a screen coordinate point with the help of an extent object and viewport dimensions of a the map
Parameters:
extent
{adf.Extent} The current extent of the {@adf.Map} object
width
{Integer} The width of the map
height
{Integer} The height of the map
point
{adf.Point} The map coordinate point to convert

<static> adf.Utils.trim(str)
Duplicates the functionality of String.trim() found in JavaScript 1.8.1
Parameters:
str
{String} the string to trim all trailing or leading whitespsce from
Deprecated:
use adf.trim() instead

Documentation generated by JsDoc Toolkit 2.1.0 on Mon May 17 2010 13:45:44 GMT-0700 (PDT)