ilog.views.faces.dhtml.renderkit
Class IlvDHTMLUtil

java.lang.Object
  extended by ilog.views.faces.dhtml.renderkit.IlvDHTMLUtil

public class IlvDHTMLUtil
extends Object

The IlvDHTMLUtil class gathers various utility methods used to render JViews Faces DHTML components.

Since:
JViews 6.0

Method Summary
static void debugDecodedParameters(UIComponent component, HashMap map)
           
static String encodeNamespace(FacesContext context, String name)
          Encodes the name parameter by prefixing it by the namespace: Portlet: Use renderResponse.getNamespace() to prefix the name.
static void endScriptSection(Writer writer)
          Renders to the writer the ending of a script section.
static IlvFacesManager findManager(FacesContext facesContext)
          Find the manager that will manage the DHTML components (scripts, dependencies).
static String getClientId(String jsRef)
          Converts a JViews JavaScript reference to its client ID.
static String getControllerPath(FacesContext facesContext)
          Returns the URL mapping of the controller servlet.
static String getControllerURL()
          Returns the URL of the controller servlet.
static String getJSRef(String clientId)
          Returns the JavaScript variable reference of a component.
static String getJSRef(UIComponent component)
          Returns the JavaScript variable reference of a component.
static Object getObjectFromModel(FacesContext facesContext, UIComponent component, String property)
          Returns the object described by the property from the model if the component has a value binding registered for this property.
static boolean isDependencyRendered(UIComponent component, IlvDependencyManager dependencyManager)
          Returns true if the dependency component has already rendered itself, false otherwise.
static void setPropertyFromModel(FacesContext context, UIComponent component, String property)
          Refresh the local value of a property with the referenced value if a value binding is defined on this property.
static void startScriptSection(Writer writer)
          Renders to the writer the starting of a script section.
static void writeJSHandler(FacesContext context, String jsRef, String jsHandler, String jsCode)
          Writes a JavaScript handler on the event generated by the component jsRef.
static void writeJSHandler(FacesContext context, String jsRef, String jsHandler, String jsCode, String[] params)
          Writes a JavaScript handler on the event generated by the component jsRef.
static void writeJSProperty(FacesContext context, String jsRef, String property, String value)
          Writes in the current response writer the JavaScript setting of a property of a component.
static void writeJSStringProperty(FacesContext context, String jsRef, String property, String value)
          Writes in the current response writer the JavaScript setting of a property of a component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isDependencyRendered

public static boolean isDependencyRendered(UIComponent component,
                                           IlvDependencyManager dependencyManager)
Returns true if the dependency component has already rendered itself, false otherwise.

Parameters:
component - The component that is being rendered.
dependencyManager - The dependency manager.
Returns:
true if the dependency component has already rendered itself, false. otherwise.
Since:
JViews 6.5

getJSRef

public static String getJSRef(String clientId)
Returns the JavaScript variable reference of a component.

Parameters:
clientId - The clientId of the component.
Returns:
The JavaScript reference of the component.

getJSRef

public static String getJSRef(UIComponent component)
Returns the JavaScript variable reference of a component.

Parameters:
component - The component whose the JavaScript variable reference is returned.
Returns:
The JavaScript reference of the component.

encodeNamespace

public static String encodeNamespace(FacesContext context,
                                     String name)
Encodes the name parameter by prefixing it by the namespace: Servlet: Return the file unchanged.

Parameters:
context - The current faces context.
name - The name to encode.
Returns:
The name parameter prefixed by the namespace.

getClientId

public static String getClientId(String jsRef)
Converts a JViews JavaScript reference to its client ID.

Parameters:
jsRef - The JavaScript reference of the component.
Returns:
The client ID of a component from its JavaScript reference.

getObjectFromModel

public static Object getObjectFromModel(FacesContext facesContext,
                                        UIComponent component,
                                        String property)
Returns the object described by the property from the model if the component has a value binding registered for this property.

Parameters:
facesContext - The current context.
component - The component processed.
property - The property processed.
Returns:
The object from the model if a value binding is registered on the component for this property.

setPropertyFromModel

public static void setPropertyFromModel(FacesContext context,
                                        UIComponent component,
                                        String property)
Refresh the local value of a property with the referenced value if a value binding is defined on this property.

Parameters:
context - The current faces context.
component - The component processed.
property - The property to refresh with the referenced value.

findManager

public static IlvFacesManager findManager(FacesContext facesContext)
Find the manager that will manage the DHTML components (scripts, dependencies).

Parameters:
facesContext - The current faces context.
Returns:
The manager.

getControllerPath

public static String getControllerPath(FacesContext facesContext)
Returns the URL mapping of the controller servlet.

Parameters:
facesContext - The current faces context.
Returns:
The URL mapping of the controller servlet.

writeJSProperty

public static void writeJSProperty(FacesContext context,
                                   String jsRef,
                                   String property,
                                   String value)
                            throws IOException
Writes in the current response writer the JavaScript setting of a property of a component. The value must be a JavaScript reference or a number. If the value is a string, use writeJSStringProperty instead.

Parameters:
context - The current faces context.
jsRef - The JavaScript reference of the component.
property - The property to set.
value - The value to set to the property.
Throws:
IOException

writeJSStringProperty

public static void writeJSStringProperty(FacesContext context,
                                         String jsRef,
                                         String property,
                                         String value)
                                  throws IOException
Writes in the current response writer the JavaScript setting of a property of a component. The value must be a JavaScript string that will be enclosed with "'" characters. If the value is a reference or a number, use writeJSProperty instead.

Parameters:
context - The current faces context.
jsRef - The JavaScript reference of the component.
property - The property to set.
value - The value to set to the property.
Throws:
IOException

writeJSHandler

public static void writeJSHandler(FacesContext context,
                                  String jsRef,
                                  String jsHandler,
                                  String jsCode,
                                  String[] params)
                           throws IOException
Writes a JavaScript handler on the event generated by the component jsRef.

Parameters:
context - The current faces context.
jsRef - The JavaScript reference of the component.
jsHandler - The name of the JavaScript handler to add.
jsCode - The code that will be executed when the specified event is sent.
params - The names of the parameters of the JavaScript handler.
Throws:
IOException

writeJSHandler

public static void writeJSHandler(FacesContext context,
                                  String jsRef,
                                  String jsHandler,
                                  String jsCode)
                           throws IOException
Writes a JavaScript handler on the event generated by the component jsRef. The implicit parameter of the listener is 'view'.

Parameters:
context - The current faces context.
jsRef - The JavaScript reference of the component.
jsHandler - The name of the JavaScript handler to add.
jsCode - The code that will be executed when the specified event is sent.
Throws:
IOException

debugDecodedParameters

public static void debugDecodedParameters(UIComponent component,
                                          HashMap map)
Internal method or field: do not use!

getControllerURL

public static String getControllerURL()
                               throws IllegalStateException
Returns the URL of the controller servlet.

Returns:
The controller servlet's URL.
Throws:
IllegalStateException - If the request's type is not handled.
Since:
JViews 7.5

startScriptSection

public static void startScriptSection(Writer writer)
                               throws IOException
Renders to the writer the starting of a script section.

Parameters:
writer - The writer
Throws:
IOException
Since:
JViews 7.5

endScriptSection

public static void endScriptSection(Writer writer)
                             throws IOException
Renders to the writer the ending of a script section.

Parameters:
writer - the writer
Throws:
IOException
Since:
JViews 7.5


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.