org.apache.myfaces.custom.dojo
Class DojoUtils

java.lang.Object
  extended by org.apache.myfaces.custom.dojo.DojoUtils

public final class DojoUtils
extends Object

Utils class for the dojo infrastructure to ease the component building mechanisms note this class uses its own double entries filter due to the fact that we can mix and match header and body scripts as needed (we do not want to lose portal functionality do we?)

Version:
$Revision: 697985 $ $Date: 2006-09-08 20:56:28 +0000 (Fri, 08 Sep 2006) $
Author:
Werner Punz (latest modification by $Author: lu4242 $)

Method Summary
static void addDebugConsole(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component)
          adds a debug console to the output this is for helping to debug the dojo system a debug:true is required for this to work properly it will not be set by this method (due to the avoidance of unwanted automatisms causing sideefects)
static void addMainInclude(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component, String javascriptLocation, DojoConfig config)
           
static void addNamespace(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component, String namespace, String location)
          adds a new namespace location to the mix
static void addProvide(javax.faces.context.FacesContext context, String provided)
          adds a dojo provide to the current list of definitions within the header
static void addProvide(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component, String provided)
          adds a dojo provide
static void addRequire(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component, String required)
          adds a dojo require include to our mix of stuff used
static void addRequire(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component, String[] requires)
          convenience method for easier requires handling
static String calculateWidgetId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent widget)
           
static String calculateWidgetVarName(javax.faces.context.FacesContext context, javax.faces.component.UIComponent widget)
           
static String calculateWidgetVarName(String clientId)
          helper method to centralize the widget variable name calculation for our dojo javascript widget init code
static String createDebugStatement(String stmnt)
          creates a debug statement for the debug console
static String createDebugStatement(String stmnt, String value)
          creates a debug statement and a corresponding value for the debug console
static String createDojoProvideScript(String provided)
          helper method which does the proper dojo provide script creation
static String createDojoRequireString(String required)
          helper method for the proper dojo require script creation
static Map getAttributeMap(javax.faces.context.FacesContext facesContext, String[] attributeNames, javax.faces.component.UIComponent component)
          creates a dojoed attribute map upon the given array of attribute names
static DojoConfig getDjConfigInstance(javax.faces.context.FacesContext context)
          Request singleton getter method for the djConfig object
static Boolean getExpanded(javax.faces.context.FacesContext facesContext)
          getter for the expanded flat
static boolean isDojoInitialized(javax.faces.context.FacesContext facesContext)
          check if dojo is going to be used
static boolean isInlineScriptCheck(javax.faces.context.FacesContext context, String inlineScript)
          check if the script with the given inlineScript-name has been added
static boolean isInlineScriptSet(javax.faces.context.FacesContext context, String inlineScript)
          Inline script set
static void mergeExternalDjConfig(javax.faces.context.FacesContext context, DojoConfig config)
          helper to merge in an external dojo config instance the merge algorithm is that an existing entry is overwritten if a new config entry is set make sure that this is not called too often due to the fact that we do heavy reflection in here
static String renderWidgetInitializationCode(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component, String dojoType, Map paramMap)
          please, instead of using standard dojo taglib mechanisms use this code for initialisation it will render a clean and proper javascript initialisation instead.
static String renderWidgetInitializationCode(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component, String dojoType, String[] attributeNames)
          convenience method to render the widget init code automatically for a given component and a set of attribute names
static String renderWidgetInitializationCode(javax.faces.context.ResponseWriter writer, javax.faces.component.UIComponent component, String dojoType, Map paramMap, String clientId, boolean refId)
          same for a given neutral id...
static void setExpanded(javax.faces.context.FacesContext facesContext, Boolean expanded)
          if this flag is set to true somewhere before the rendering, the expanded version is loaded otherwise the nonexpanded version is loaded
static void writeDebugStatement(javax.faces.context.ResponseWriter writer, String stmnt)
          helper to write out debug statements this is only a convenience method to reduce the code bloat
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAttributeMap

public static Map getAttributeMap(javax.faces.context.FacesContext facesContext,
                                  String[] attributeNames,
                                  javax.faces.component.UIComponent component)
creates a dojoed attribute map upon the given array of attribute names

Parameters:
facesContext - standard faces context used internally
attributeNames - string array of traversable attribute names
component - the source component with the values set
Returns:
a map which resembles the attribute map for further processing

addDebugConsole

public static void addDebugConsole(javax.faces.context.FacesContext facesContext,
                                   javax.faces.component.UIComponent component)
                            throws IOException
adds a debug console to the output this is for helping to debug the dojo system a debug:true is required for this to work properly it will not be set by this method (due to the avoidance of unwanted automatisms causing sideefects)

Parameters:
facesContext -
component -
Throws:
IOException

isDojoInitialized

public static boolean isDojoInitialized(javax.faces.context.FacesContext facesContext)
check if dojo is going to be used


addMainInclude

public static void addMainInclude(javax.faces.context.FacesContext facesContext,
                                  javax.faces.component.UIComponent component,
                                  String javascriptLocation,
                                  DojoConfig config)
                           throws IOException
Throws:
IOException

addNamespace

public static void addNamespace(javax.faces.context.FacesContext facesContext,
                                javax.faces.component.UIComponent component,
                                String namespace,
                                String location)
                         throws IOException
adds a new namespace location to the mix

Parameters:
facesContext - the faces context which is used internally
component - the affected component
namespace - the namespace which has to be applied
location - the script location
Throws:
IOException

addProvide

public static void addProvide(javax.faces.context.FacesContext context,
                              String provided)
adds a dojo provide to the current list of definitions within the header

Parameters:
context - the faces context for accessing the resources internally
provided - the package with the class provided by this implementation
See Also:
Dojo-Widget-Authoring for an example on this

addProvide

public static void addProvide(javax.faces.context.FacesContext facesContext,
                              javax.faces.component.UIComponent component,
                              String provided)
                       throws IOException
adds a dojo provide

Parameters:
facesContext -
component -
provided -
Throws:
IOException

addRequire

public static void addRequire(javax.faces.context.FacesContext facesContext,
                              javax.faces.component.UIComponent component,
                              String[] requires)
                       throws IOException
convenience method for easier requires handling

Parameters:
facesContext - standard faces context
component - the component
requires - an array of requires which is rendered into single dojo.require statements
Throws:
IOException

addRequire

public static void addRequire(javax.faces.context.FacesContext facesContext,
                              javax.faces.component.UIComponent component,
                              String required)
                       throws IOException
adds a dojo require include to our mix of stuff used

Parameters:
facesContext -
required -
Throws:
IOException

createDebugStatement

public static String createDebugStatement(String stmnt)
creates a debug statement for the debug console

Parameters:
stmnt - the debug message displayed by the debug console
Returns:
javaScriptcode String

createDebugStatement

public static String createDebugStatement(String stmnt,
                                          String value)
creates a debug statement and a corresponding value for the debug console

Parameters:
stmnt - the debug message displayed and given value by the debug console
Returns:
javaScriptcode String

createDojoProvideScript

public static String createDojoProvideScript(String provided)
helper method which does the proper dojo provide script creation

Parameters:
provided - the provided class name
Returns:
dojoProvide String

createDojoRequireString

public static String createDojoRequireString(String required)
helper method for the proper dojo require script creation

Parameters:
required - the creation package for the require functionality
Returns:
dojoRequire String

getDjConfigInstance

public static DojoConfig getDjConfigInstance(javax.faces.context.FacesContext context)
Request singleton getter method for the djConfig object

Parameters:
context -
Returns:

getExpanded

public static Boolean getExpanded(javax.faces.context.FacesContext facesContext)
getter for the expanded flat

Parameters:
facesContext -
Returns:

isInlineScriptSet

public static boolean isInlineScriptSet(javax.faces.context.FacesContext context,
                                        String inlineScript)
Inline script set

Parameters:
context - standard faces context
inlineScript - key to the inline script
Returns:
true if the inline script already is set

isInlineScriptCheck

public static boolean isInlineScriptCheck(javax.faces.context.FacesContext context,
                                          String inlineScript)
check if the script with the given inlineScript-name has been added


renderWidgetInitializationCode

public static String renderWidgetInitializationCode(javax.faces.context.FacesContext facesContext,
                                                    javax.faces.component.UIComponent component,
                                                    String dojoType,
                                                    Map paramMap)
                                             throws IOException
please, instead of using standard dojo taglib mechanisms use this code for initialisation it will render a clean and proper javascript initialisation instead. There are issues with ADF and the dojo taglib mechanisms and also (Alex Russel wont like to hear this) the dojo taglib initialisation fails on W3C validations. returns the name of the javascript var for further processing

Parameters:
facesContext - standard faces context
component - standard component
dojoType - the dojo type of this component
paramMap -
Throws:
IOException

renderWidgetInitializationCode

public static String renderWidgetInitializationCode(javax.faces.context.FacesContext facesContext,
                                                    javax.faces.component.UIComponent component,
                                                    String dojoType,
                                                    String[] attributeNames)
                                             throws IOException
convenience method to render the widget init code automatically for a given component and a set of attribute names

Parameters:
facesContext -
component -
dojoType -
attributeNames -
Returns:
Throws:
IOException

renderWidgetInitializationCode

public static String renderWidgetInitializationCode(javax.faces.context.ResponseWriter writer,
                                                    javax.faces.component.UIComponent component,
                                                    String dojoType,
                                                    Map paramMap,
                                                    String clientId,
                                                    boolean refId)
                                             throws IOException
same for a given neutral id...

Parameters:
dojoType -
paramMap -
clientId - the referencing id which the widget has to render to (note the id is enforced the uicomponent does nothing in this case!!!!)
refId - if true the refid is set in the dojo javascript init code if false no ref is set the false often is needed for containers which dynamically generated widgets with no referencing div
Returns:
a string with the name of the javascript variable
Throws:
IOException

calculateWidgetVarName

public static String calculateWidgetVarName(String clientId)
helper method to centralize the widget variable name calculation for our dojo javascript widget init code

Parameters:
clientId - the client id upon which the var name has to be generated
Returns:
the javascript widget var name for the given client id

calculateWidgetId

public static String calculateWidgetId(javax.faces.context.FacesContext context,
                                       javax.faces.component.UIComponent widget)
Returns:

calculateWidgetVarName

public static String calculateWidgetVarName(javax.faces.context.FacesContext context,
                                            javax.faces.component.UIComponent widget)
Returns:

mergeExternalDjConfig

public static void mergeExternalDjConfig(javax.faces.context.FacesContext context,
                                         DojoConfig config)
helper to merge in an external dojo config instance the merge algorithm is that an existing entry is overwritten if a new config entry is set make sure that this is not called too often due to the fact that we do heavy reflection in here

Parameters:
context -
config -

setExpanded

public static void setExpanded(javax.faces.context.FacesContext facesContext,
                               Boolean expanded)
if this flag is set to true somewhere before the rendering, the expanded version is loaded otherwise the nonexpanded version is loaded

Parameters:
facesContext - context because we again have a full request singleton here
expanded - if set to true the expanded version of the dojo scripts are loaded otherwise the non expanded ones are loaded

writeDebugStatement

public static void writeDebugStatement(javax.faces.context.ResponseWriter writer,
                                       String stmnt)
                                throws IOException
helper to write out debug statements this is only a convenience method to reduce the code bloat

Parameters:
writer -
stmnt -
Throws:
IOException


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.