Class UtilHandlers

java.lang.Object
org.glassfish.admingui.common.handlers.UtilHandlers

public class UtilHandlers extends Object
Author:
Jennifer Chou
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of UtilHandlers
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addEmptyFirstElement(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
     
    static void
    addHandler(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
     
    static void
    calendarAdd(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    Adds the specified (signed) amount of time to the given calendar field, based on the calendar's rules and returns the resulting Date.
    static void
    compare(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    Compare if 2 objects is equal
    static void
    containedIn(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    Test if a list Listcontains the string
    static void
    convertArrayToCommaString(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
     
    static void
    convertListToArray(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
     
    static void
    convertListToCommaString(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
     
    static void
    convertMapToListOfMap(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    This method converts a Map into a list of Map with keyName and ValueName.
    static void
    convertStringtoListHandler(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    This handler takes in a string with delimiter and returns list
    static void
    convertStringToMap(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
     
    static void
    convertStrToBoolean(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
     
    static void
    createDefaultViewRoot(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    This method returns a new UIViewRoot with the basic JSFT settings from the current ViewRoot.
    static void
    createPropertyString(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
     
    static void
    decodeString(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    This method decodes a String using "UTF-8" as default if scheme is not specified.
    static void
    encodeId(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    This handler invokes the GuiUtil.genId(String) method and returns the result.
    static String
     
    static void
    fileGetName(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    Returns the name of the file or directory denoted by this abstract pathname.
    static boolean
    foreach(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    This handler provides the foreach loop functionality.
    static boolean
    forLoop(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    A utility handler that resembles the for() method in Java.
    static void
    formatPathSeperatorStringsforSaving(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
     
    static void
    formatStringsforDisplay(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
     
    static void
    getFile(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    Creates a new File instance by converting the given pathname string into an abstract pathname.
    static void
    getListBoxOptions(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
     
    static void
    getMapKeys(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    Returns the keys
    static void
    javaToJSON(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    This handler will convert a Java object to JSON by using JSONUtil.javaToJSON(java.lang.Object, int).
    static void
    listAdd(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    Adds the given value to a List
    static void
    listCombine(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    Combine 2 lists List by adding the object in the 2nd list to the first list
    static void
    listRemove(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    Remove the given value from a List
    static void
    listSort(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    sort a List
    static void
    logger(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
     
    static void
    mapCopy(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    Returns a duplicate copy of the source Map
    static void
    mapEntrySet(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    This handler returns the Set of entries for the given Map.
    static void
    mapGet(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    Returns the value to which the input map maps the input key.
    static void
    mapJoin(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
     
    static void
    mapValueNullToFalse(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    This handler goes through all the Map entries, if the value is null, it will convert that to "false" This is used usually to take care of un-checked checkbox which is set to 'null', but needs to be set to false when the map is passed in as attrsMap for request.
    static void
    mapValues(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    This handler returns the Set of keys for the given Map.
    static void
    prepareAlertMsg(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    This method sets the attributes that will be used by the alert component display the message to user.
    static void
    prepareSuccessful(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    This method displays the save successful message when the page refresh.
    static void
    resolveTokens(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
     
    static void
    roundTo2DecimalPoint(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
     
    static void
    serveResource(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext ctx)
    This handler serves a resource via JSFTemplating's FileStreamer.
    static void
    startsWith(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    This handler will test if a String starts with another String.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UtilHandlers

      public UtilHandlers()
      Creates a new instance of UtilHandlers
  • Method Details

    • calendarAdd

      public static void calendarAdd(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      Adds the specified (signed) amount of time to the given calendar field, based on the calendar's rules and returns the resulting Date. See java.util.GregorianCalendar add(int field, int amount).

      Input value: "Field" -- Type: Integer - java.util.Calendar field

      Input value: "Amount" -- Type: Integer - the amount of date or time to be added to the field.

      Output value: "Date" -- Type: java.util.Date

      Parameters:
      handlerCtx - The HandlerContext.
    • getFile

      public static void getFile(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      Creates a new File instance by converting the given pathname string into an abstract pathname. If the given string is the empty string, then the result is the empty abstract pathname.

      Input value: "Pathname" -- Type: String

      Output value: "File" -- Type: java.io.File

      Parameters:
      handlerCtx - The HandlerContext.
    • serveResource

      public static void serveResource(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext ctx) throws IOException

      This handler serves a resource via JSFTemplating's FileStreamer.

      Throws:
      IOException
    • fileGetName

      public static void fileGetName(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      Returns the name of the file or directory denoted by this abstract pathname. This is just the last name in the pathname's name sequence. If the pathname's name sequence is empty, then the empty string is returned.

      Input value: "File" -- Type: java.io.File

      Output value: "Name" -- Type: String

      Parameters:
      handlerCtx - The HandlerContext.
    • mapCopy

      public static void mapCopy(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      Returns a duplicate copy of the source Map

      Input value: "source" -- Type: java.util.Map

      Output value: "dest" -- Type: java.util.Map

      Parameters:
      handlerCtx - The HandlerContext.
    • mapGet

      public static void mapGet(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      Returns the value to which the input map maps the input key.

      Input value: "Map" -- Type: java.util.Map

      Input value: "Key" -- Type: Object

      Output value: "Value" -- Type: Object

      Parameters:
      handlerCtx - The HandlerContext.
    • mapJoin

      public static void mapJoin(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    • mapValueNullToFalse

      public static void mapValueNullToFalse(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
      This handler goes through all the Map entries, if the value is null, it will convert that to "false" This is used usually to take care of un-checked checkbox which is set to 'null', but needs to be set to false when the map is passed in as attrsMap for request.

      Returns the map

      Input value: "map" -- Type: java.util.Map

      Input value: "key" -- Type: java.util.List

      Parameters:
      handlerCtx - The HandlerContext.
    • getMapKeys

      public static void getMapKeys(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      Returns the keys

      Input value: "Map" -- Type: java.util.Map

      Output value: "Keys" -- Type: Object

      Parameters:
      handlerCtx - The HandlerContext.
    • listAdd

      public static void listAdd(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      Adds the given value to a List

      Input list: "list" -- Type: java.util.List

      Input value: "value" -- Type: java.lang.Object

      Input value: "index" -- Type: Integer

      Parameters:
      handlerCtx - The HandlerContext
    • listRemove

      public static void listRemove(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      Remove the given value from a List

      if it is present

      Input list: "list" -- Type: java.util.List

      Input value: "value" -- Type: java.lang.Object

      Parameters:
      handlerCtx - The HandlerContext
    • listSort

      public static void listSort(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      sort a List

      Input list: "list" -- Type: java.util.List

      Parameters:
      handlerCtx - The HandlerContext
    • listCombine

      public static void listCombine(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      Combine 2 lists List by adding the object in the 2nd list to the first list

      Input value: "list" -- Type: java.util.List

      Input value: "list2" -- Type: java.util.List

      Parameters:
      handlerCtx - The HandlerContext
    • containedIn

      public static void containedIn(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      Test if a list Listcontains the string

      Input value: "list" -- Type: java.util.List

      Input value: "testStr" -- Type: String

      Output value: "contain" -- Type: Boolean

    • compare

      public static void compare(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      Compare if 2 objects is equal

      Input value: "obj1" -- Type: Object

      Input value: "obj2" -- Type: Object

      Output value: "equal" -- Type: Object

      Parameters:
      handlerCtx - The HandlerContext.
    • prepareSuccessful

      public static void prepareSuccessful(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      This method displays the save successful message when the page refresh.

      Parameters:
      handlerCtx - The HandlerContext.
    • prepareAlertMsg

      public static void prepareAlertMsg(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      This method sets the attributes that will be used by the alert component display the message to user. If type is not specifed, it will be 'info' by default.

      Input value: "summary" -- Type: java.lang.String

      Input value: "type" -- Type: java.lang.String

      Input value: "detail" -- Type: java.lang.String

      Parameters:
      handlerCtx - The HandlerContext.
    • startsWith

      public static void startsWith(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      This handler will test if a String starts with another String.

    • decodeString

      public static void decodeString(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      This method decodes a String using "UTF-8" as default if scheme is not specified.

    • roundTo2DecimalPoint

      public static void roundTo2DecimalPoint(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    • addEmptyFirstElement

      public static void addEmptyFirstElement(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    • getListBoxOptions

      public static void getListBoxOptions(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    • convertArrayToCommaString

      public static void convertArrayToCommaString(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    • convertListToCommaString

      public static void convertListToCommaString(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    • resolveTokens

      public static void resolveTokens(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    • convertListToArray

      public static void convertListToArray(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    • convertStringtoListHandler

      public static void convertStringtoListHandler(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      This handler takes in a string with delimiter and returns list

    • convertStringToMap

      public static void convertStringToMap(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    • formatStringsforDisplay

      public static void formatStringsforDisplay(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    • formatPathSeperatorStringsforSaving

      public static void formatPathSeperatorStringsforSaving(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    • addHandler

      public static void addHandler(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    • forLoop

      public static boolean forLoop(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      A utility handler that resembles the for() method in Java. Handler inside the for loop will be executed in a loop. start index is specified by "start", till less than "end". eg. forLoop(start="1" end="3" varName="foo"){}, handler inside the {} will be executed 2 times.

      Input value: "start" -- Type: Integer Start index, default to Zero is not specified

      Input value: "end" -- Type: Integer End index.

      Input value: "varName" -- Type: String Variable to be replaced in the for loop by the index.

      Parameters:
      handlerCtx - The HandlerContext.
    • foreach

      public static boolean foreach(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      This handler provides the foreach loop functionality. You should specify a request attribute 'var' that will be used as the key for storing each token in the list. You can then retreive each value as the loop iterates by requesting the request scoped attribute keyed by the value you suplied for 'var'. You must also specify the List<Object> to iterate over.

    • mapEntrySet

      public static void mapEntrySet(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      This handler returns the Set of entries for the given Map.

    • mapValues

      public static void mapValues(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      This handler returns the Set of keys for the given Map.

    • convertStrToBoolean

      public static void convertStrToBoolean(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    • logger

      public static void logger(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    • createDefaultViewRoot

      public static void createDefaultViewRoot(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      This method returns a new UIViewRoot with the basic JSFT settings from the current ViewRoot. If you intend to set this before the current view is created (in an effort to swap out the UIViewRoot), you should do so during the initPage event (take care to only do this during the first request, or you might lose all child components).

    • encodeId

      public static void encodeId(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      This handler invokes the GuiUtil.genId(String) method and returns the result.

    • convertMapToListOfMap

      public static void convertMapToListOfMap(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
      This method converts a Map into a list of Map with keyName and ValueName. This is suitable for table dislay.
    • javaToJSON

      public static void javaToJSON(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

      This handler will convert a Java object to JSON by using JSONUtil.javaToJSON(java.lang.Object, int).

    • createPropertyString

      public static void createPropertyString(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
    • escapePropertyValue

      public static String escapePropertyValue(String str)