com.icesoft.faces.context.effects

## Class JavascriptContext

- java.lang.Object
- - com.icesoft.faces.context.effects.JavascriptContext

-     public class JavascriptContext
      extends java.lang.Object

  Used to send Javascript to the browser

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DYNAMIC_CODE_ID` ID of script node used to send Javascript in a dom update
    `static java.lang.String` | `ICE_BRIDGE` URL of the ICE Bridge lib
    `static java.lang.String` | `ICE_EXTRAS` URL of the ICE Extras lib
    `static java.lang.String` | `LIB_KEY` Request Scope Key, indicating that extras needs to be included

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JavascriptContext()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addJavascriptCall(javax.faces.context.FacesContext facesContext, java.lang.String call)` Add a javascript call to be executed on the browser.
    `static void` | `applicationFocus(javax.faces.context.FacesContext facesContext, java.lang.String id)` Set the application focus for the current request, overrides and setFocus call.
    `static java.lang.String` | `applyEffect(Effect effect, java.lang.String id, javax.faces.context.FacesContext context)` Wrap the effect in a javascript method to be called later.
    `static void` | `fireEffect(Effect effect, java.lang.String id, javax.faces.context.FacesContext context)` Fire an effect at the end of the current render cycle.
    `static void` | `fireEffect(Effect effect, javax.faces.component.UIComponent component)` Fire an effect at the end of the current render cycle
    `static void` | `fireEffect(Effect effect, javax.faces.component.UIComponent component, javax.faces.context.FacesContext facesContext)` Fire an effect at the end of the current render cycle
    `static void` | `fireEffect(javax.faces.component.UIComponent uiComponent, javax.faces.context.FacesContext facesContext)` Fire an effect at the end of the current render cycle
    `static void` | `focus(javax.faces.context.FacesContext context, java.lang.String id)` \ Set focus on an HTML element.
    `static java.lang.String` | `getEffectFunctionForEvent(javax.faces.component.UIComponent uiComponent, java.lang.String event, java.lang.String id, javax.faces.context.FacesContext facesContext)` Get the Effect function for a given event
    `static java.lang.String[]` | `getIncludedLibs(javax.faces.context.FacesContext facesContext)` Get the included javascript libraries
    `static java.lang.String` | `getJavascriptCalls(javax.faces.context.FacesContext facesContext)` Add a javascript call to this request
    `static java.lang.String` | `getJavascriptCalls(java.util.Map map)` Get javascript calls from the Request map
    `static void` | `includeLib(java.lang.String libname, javax.faces.context.FacesContext facesContext)` Include a script tag in the <head> section of the page with the src attribute set to libname.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### LIB_KEY

          public static final java.lang.String LIB_KEY

      Request Scope Key, indicating that extras needs to be included
      See Also:
        Constant Field Values

    - #### DYNAMIC_CODE_ID

          public static final java.lang.String DYNAMIC_CODE_ID

      ID of script node used to send Javascript in a dom update
      See Also:
        Constant Field Values

    - #### ICE_BRIDGE

          public static final java.lang.String ICE_BRIDGE

      URL of the ICE Bridge lib

    - #### ICE_EXTRAS

          public static final java.lang.String ICE_EXTRAS

      URL of the ICE Extras lib

  - ### Constructor Detail

    - #### JavascriptContext

          public JavascriptContext()

  - ### Method Detail

    - #### includeLib

          public static void includeLib(java.lang.String libname,
                                        javax.faces.context.FacesContext facesContext)

      Include a script tag in the <head> section of the page with the src attribute set to libname. This will insure that all icefaces pages contain this script for the remainder of the session.
      Parameters:
        `libname` - the source of the javascript file
        `facesContext` - The facescontext this file is needed for

    - #### getIncludedLibs

          public static java.lang.String[] getIncludedLibs(javax.faces.context.FacesContext facesContext)

      Get the included javascript libraries
      Parameters:
        `facesContext` -
      Returns:

    - #### addJavascriptCall

          public static void addJavascriptCall(javax.faces.context.FacesContext facesContext,
                                               java.lang.String call)

      Add a javascript call to be executed on the browser. Code will be executed at the end of the current render cycle.

      Note: When sending function definitions you must specify the function name as this['functionName'] = function(){} For example: `helloWorld(name}{ alert('Hello [' + name + ']'); }`

      Would need to be written as `this['helloWorld'] = function(name){ alert('Hello [' + name + ']'); }`
      Parameters:
        `facesContext` -
        `call` - Javascript code to execute

    - #### getJavascriptCalls

          public static java.lang.String getJavascriptCalls(javax.faces.context.FacesContext facesContext)

      Add a javascript call to this request
      Parameters:
        `facesContext` -
      Returns:

    - #### getJavascriptCalls

          public static java.lang.String getJavascriptCalls(java.util.Map map)

      Get javascript calls from the Request map
      Parameters:
        `map` -
      Returns:

    - #### applyEffect

          public static java.lang.String applyEffect(Effect effect,
                                                     java.lang.String id,
                                                     javax.faces.context.FacesContext context)

      Wrap the effect in a javascript method to be called later. Returns the method name. Used in local effects.
      Parameters:
        `effect` -
        `id` -
        `context` -
      Returns:
        The name of the method that wraps the effect

    - #### fireEffect

          public static void fireEffect(Effect effect,
                                        java.lang.String id,
                                        javax.faces.context.FacesContext context)

      Fire an effect at the end of the current render cycle. Fired from server, non local.
      Parameters:
        `effect` -
        `id` - Target element of the effect
        `context` -

    - #### fireEffect

          public static void fireEffect(Effect effect,
                                        javax.faces.component.UIComponent component)

      Fire an effect at the end of the current render cycle
      Parameters:
        `effect` -
        `component` -

    - #### fireEffect

          public static void fireEffect(Effect effect,
                                        javax.faces.component.UIComponent component,
                                        javax.faces.context.FacesContext facesContext)

      Fire an effect at the end of the current render cycle
      Parameters:
        `effect` -
        `component` -
        `facesContext` -

    - #### fireEffect

          public static void fireEffect(javax.faces.component.UIComponent uiComponent,
                                        javax.faces.context.FacesContext facesContext)

      Fire an effect at the end of the current render cycle
      Parameters:
        `uiComponent` -
        `facesContext` -

    - #### getEffectFunctionForEvent

          public static java.lang.String getEffectFunctionForEvent(javax.faces.component.UIComponent uiComponent,
                                                                   java.lang.String event,
                                                                   java.lang.String id,
                                                                   javax.faces.context.FacesContext facesContext)

      Get the Effect function for a given event
      Parameters:
        `uiComponent` -
        `event` -
        `id` -
        `facesContext` -
      Returns:

    - #### focus

          public static void focus(javax.faces.context.FacesContext context,
                                   java.lang.String id)

      \ Set focus on an HTML element.
      Parameters:
        `context` -
        `id` -

    - #### applicationFocus

          public static void applicationFocus(javax.faces.context.FacesContext facesContext,
                                              java.lang.String id)

      Set the application focus for the current request, overrides and setFocus call. Generally setFocus is used by components, while setApplicationFocus is used by the application.
      Parameters:
        `id` -

Copyright 2025 ICEsoft Technologies Canada, Corp. All Rights Reserved.