org.directwebremoting.ui.dwr
Class Util

java.lang.Object
  extended by org.directwebremoting.ui.dwr.Util

public class Util
extends java.lang.Object

Util is a server-side proxy that allows Java programmers to call client side Javascript from Java.

Each Util object is associated with a list of ScriptSessions and the proxy code is creates will be dynamically forwarded to all those browsers.

Currently this class contains only the write-only DOM manipulation functions from Util. It is possible that we could add the read methods, however the complexity in the callback and the fact that you are probably not going to need it means that we'll leave it for another day. Specifically, getValue, getValues and getText have been left out as being read functions and useLoadingMessage etc have been left out as not being DOM related.

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Constructor Summary
Util()
           
 
Method Summary
static void addClassName(java.lang.String elementId, java.lang.String className)
          $(ele).className += "X", that we can call from Java easily.
static void addOptions(java.lang.String elementId, java.util.Collection<?> array, java.lang.String property)
          Add options to a list from an array or map.
static void addOptions(java.lang.String elementId, java.util.Collection<?> array, java.lang.String valueProperty, java.lang.String textProperty)
          Add options to a list from an array or map.
static void addOptions(java.lang.String elementId, java.lang.String[] array)
          Add options to a list from an array or map.
static void addRows(java.lang.String elementId, java.util.Collection<java.util.Collection<java.lang.String>> data)
          Create rows inside a the table, tbody, thead or tfoot element (given by id).
static void addRows(java.lang.String elementId, java.util.Collection<java.util.Collection<java.lang.String>> data, java.lang.String options)
          Create rows inside a the table, tbody, thead or tfoot element (given by id).
static void addRows(java.lang.String elementId, java.lang.String[][] data)
          Create rows inside a the table, tbody, thead or tfoot element (given by id).
static void addRows(java.lang.String elementId, java.lang.String[][] data, java.lang.String options)
          Create rows inside a the table, tbody, thead or tfoot element (given by id).
static void cloneNode(java.lang.String elementId)
          Clone a given node.
static void cloneNode(java.lang.String elementId, java.lang.String idPrefix, java.lang.String idSuffix)
          Clone a given node.
static void removeAllOptions(java.lang.String elementId)
          Remove all the options from a select list (specified by id)
static void removeAllRows(java.lang.String elementId)
          Remove all the children of a given node.
static void removeClassName(java.lang.String elementId, java.lang.String className)
          $(ele).className -= "X", that we can call from Java easily From code originally by Gavin Kistner
static void removeNode(java.lang.String elementId)
          Sets a CSS style on an element
static void setClassName(java.lang.String elementId, java.lang.String className)
          $(ele).className = "X", that we can call from Java easily
static void setStyle(java.lang.String elementId, java.lang.String selector, java.lang.String value)
          Sets a CSS style on an element
static void setValue(java.lang.String elementId, java.lang.Object value)
          Set the value an HTML element to the specified value.
static void setValue(java.lang.String elementId, java.lang.Object value, boolean escapeHtml)
          Set the value an HTML element to the specified value.
static void setValues(java.util.Map<?,?> values, boolean escapeHtml)
          Given a map, call setValue() for all the entries in the map using the entry key as an element id.
static void toggleClassName(java.lang.String elementId, java.lang.String className)
          $(ele).className |= "X", that we can call from Java easily.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

setValue

public static void setValue(java.lang.String elementId,
                            java.lang.Object value)
Set the value an HTML element to the specified value.

More.

Parameters:
elementId - The HTML element to update (by id)
value - The text to insert into the HTML element

setValue

public static void setValue(java.lang.String elementId,
                            java.lang.Object value,
                            boolean escapeHtml)
Set the value an HTML element to the specified value.

More.

Parameters:
elementId - The HTML element to update (by id)
value - The text to insert into the HTML element
escapeHtml - Should we escape HTML characters?

setValues

public static void setValues(java.util.Map<?,?> values,
                             boolean escapeHtml)
Given a map, call setValue() for all the entries in the map using the entry key as an element id.

More.

Parameters:
values - The map of elementIds to values to alter
escapeHtml - Should we escape HTML characters?

addOptions

public static void addOptions(java.lang.String elementId,
                              java.lang.String[] array)
Add options to a list from an array or map.

More.

Parameters:
elementId - The HTML element to update (by id)
array - An array of strings to use as both value and text of options

addOptions

public static void addOptions(java.lang.String elementId,
                              java.util.Collection<?> array,
                              java.lang.String property)
Add options to a list from an array or map.

More.

Parameters:
elementId - The HTML element to update (by id)
array - And array of objects from which to create options
property - The object property to use for the option value and text

addOptions

public static void addOptions(java.lang.String elementId,
                              java.util.Collection<?> array,
                              java.lang.String valueProperty,
                              java.lang.String textProperty)
Add options to a list from an array or map.

More.

Parameters:
elementId - The HTML element to update (by id)
array - And array of objects from which to create options
valueProperty - The object property to use for the option value
textProperty - The object property to use for the option text

removeAllOptions

public static void removeAllOptions(java.lang.String elementId)
Remove all the options from a select list (specified by id)

More.

Parameters:
elementId - The HTML element to update (by id)

addRows

public static void addRows(java.lang.String elementId,
                           java.lang.String[][] data,
                           java.lang.String options)
Create rows inside a the table, tbody, thead or tfoot element (given by id).

More.

Parameters:
elementId - The HTML element to update (by id)
data - The cells to add to the table
options - See link above for documentation on the options

addRows

public static void addRows(java.lang.String elementId,
                           java.lang.String[][] data)
Create rows inside a the table, tbody, thead or tfoot element (given by id).

More.

Parameters:
elementId - The HTML element to update (by id)
data - The cells to add to the table

addRows

public static void addRows(java.lang.String elementId,
                           java.util.Collection<java.util.Collection<java.lang.String>> data,
                           java.lang.String options)
Create rows inside a the table, tbody, thead or tfoot element (given by id).

More.

Parameters:
elementId - The HTML element to update (by id)
data - The cells to add to the table
options - See link above for documentation on the options

addRows

public static void addRows(java.lang.String elementId,
                           java.util.Collection<java.util.Collection<java.lang.String>> data)
Create rows inside a the table, tbody, thead or tfoot element (given by id).

More.

Parameters:
elementId - The HTML element to update (by id)
data - The cells to add to the table

removeAllRows

public static void removeAllRows(java.lang.String elementId)
Remove all the children of a given node.

More.

Parameters:
elementId - The HTML element to update (by id)

cloneNode

public static void cloneNode(java.lang.String elementId)
Clone a given node.

More.

Parameters:
elementId - The HTML element to update (by id)

cloneNode

public static void cloneNode(java.lang.String elementId,
                             java.lang.String idPrefix,
                             java.lang.String idSuffix)
Clone a given node.

More.

Parameters:
elementId - The HTML element to update (by id)
idPrefix - How do we prefix ids in the cloned version of the node tree
idSuffix - How do we suffix ids in the cloned version of the node tree

removeNode

public static void removeNode(java.lang.String elementId)
Sets a CSS style on an element

Parameters:
elementId - The HTML element to update (by id)

setClassName

public static void setClassName(java.lang.String elementId,
                                java.lang.String className)
$(ele).className = "X", that we can call from Java easily

Parameters:
elementId - The HTML element to update (by id)
className - The CSS class to set for the element

addClassName

public static void addClassName(java.lang.String elementId,
                                java.lang.String className)
$(ele).className += "X", that we can call from Java easily.

Parameters:
elementId - The HTML element to update (by id)
className - The CSS class to add to the element

removeClassName

public static void removeClassName(java.lang.String elementId,
                                   java.lang.String className)
$(ele).className -= "X", that we can call from Java easily From code originally by Gavin Kistner

Parameters:
elementId - The HTML element to update (by id)
className - The CSS class to remove from the element

toggleClassName

public static void toggleClassName(java.lang.String elementId,
                                   java.lang.String className)
$(ele).className |= "X", that we can call from Java easily.

Parameters:
elementId - The HTML element to update (by id)
className - The CSS class to toggle on/off

setStyle

public static void setStyle(java.lang.String elementId,
                            java.lang.String selector,
                            java.lang.String value)
Sets a CSS style on an element

Parameters:
elementId - The HTML element to update (by id)
selector - The CSS selector to update
value - The new value for the CSS class on the given element

Copyright 2008