Class UtilHandlers
- java.lang.Object
-
- org.glassfish.admingui.common.handlers.UtilHandlers
-
public class UtilHandlers extends Object
- Author:
- Jennifer Chou
-
-
Constructor Summary
Constructors Constructor Description UtilHandlers()
Creates a new instance of UtilHandlers
-
Method Summary
All Methods Static Methods Concrete Methods 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 equalstatic void
containedIn(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
Test if a listList
contains the stringstatic 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 liststatic 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 theGuiUtil.genId(String)
method and returns the result.static String
escapePropertyValue(String str)
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 keysstatic void
javaToJSON(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
This handler will convert a Java object to JSON by usingJsonUtil.getJsonValue(java.lang.Object)
.static void
listAdd(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
Adds the given value to aList
static void
listCombine(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
Combine 2 listsList
by adding the object in the 2nd list to the first liststatic void
listGet(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
Get an element form aList
static void
listRemove(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
Remove the given value from aList
static void
listSort(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
sort aList
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 Mapstatic void
mapEntrySet(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
This handler returns theSet
of entries for the givenMap
.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 theSet
of keys for the givenMap
.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.
-
-
-
Method Detail
-
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
fieldInput 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.
- Parameters:
ctx
-- 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
if it is presentList
Input list: "list" -- Type:
java.util.List
Input value: "value" -- Type:
java.lang.Object
- Parameters:
handlerCtx
- The HandlerContext
-
listGet
public static void listGet(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
Get an element form a
using the index number providedList
Input list: "list" -- Type:
java.util.List
Input index: "index" -- Type:
java.lang.Integer
- 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 listInput 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
List
contains the stringInput value: "list" -- Type:
java.util.List
Input value: "testStr" -- Type:
String
Output value: "contain" -- Type:
Boolean
- Parameters:
handlerCtx
-
-
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.
- Parameters:
handlerCtx
-
-
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.
- Parameters:
handlerCtx
-
-
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
- Parameters:
handlerCtx
-
-
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)
- Parameters:
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 specifiedInput 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.- Returns:
-
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 retrieve each value as the loop iterates by requesting the request scoped attribute keyed by the value you supplied for 'var'. You must also specify the
List<Object>
to iterate over.- Parameters:
handlerCtx
-- Returns:
-
mapEntrySet
public static void mapEntrySet(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
This handler returns the
Set
of entries for the givenMap
.- Parameters:
handlerCtx
-
-
mapValues
public static void mapValues(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
This handler returns the
Set
of keys for the givenMap
.- Parameters:
handlerCtx
-
-
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).
- Parameters:
handlerCtx
-
-
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.- Parameters:
handlerCtx
-
-
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 display.- Parameters:
handlerCtx
-
-
javaToJSON
public static void javaToJSON(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
This handler will convert a Java object to JSON by usingJsonUtil.getJsonValue(java.lang.Object)
.- Parameters:
handlerCtx
-
-
createPropertyString
public static void createPropertyString(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
-
-