Class UtilHandlers
- Author:
- Jennifer Chou
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddEmptyFirstElement(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) static voidaddHandler(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) static voidcalendarAdd(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 voidcompare(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) Compare if 2 objects is equalstatic voidcontainedIn(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) Test if a listListcontains the stringstatic voidconvertArrayToCommaString(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) static voidconvertListToArray(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) static voidconvertListToCommaString(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) static voidconvertMapToListOfMap(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) This method converts a Map into a list of Map with keyName and ValueName.static voidconvertStringtoListHandler(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) This handler takes in a string with delimiter and returns liststatic voidconvertStringToMap(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) static voidconvertStrToBoolean(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) static voidcreateDefaultViewRoot(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) This method returns a new UIViewRoot with the basic JSFT settings from the current ViewRoot.static voidcreatePropertyString(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) static voiddecodeString(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) This method decodes a String using "UTF-8" as default if scheme is not specified.static voidencodeId(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) This handler invokes theGuiUtil.genId(String)method and returns the result.static Stringstatic voidfileGetName(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) Returns the name of the file or directory denoted by this abstract pathname.static booleanforeach(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) This handler provides the foreach loop functionality.static booleanforLoop(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) A utility handler that resembles the for() method in Java.static voidformatPathSeperatorStringsforSaving(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) static voidformatStringsforDisplay(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) static voidgetFile(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) Creates a new File instance by converting the given pathname string into an abstract pathname.static voidgetListBoxOptions(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) static voidgetMapKeys(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) Returns the keysstatic voidjavaToJSON(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) This handler will convert a Java object to JSON by usingJSONUtil.javaToJSON(java.lang.Object, int).static voidlistAdd(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) Adds the given value to aListstatic voidlistCombine(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) Combine 2 listsListby adding the object in the 2nd list to the first liststatic voidlistRemove(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) Remove the given value from aListstatic voidlistSort(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) sort aListstatic voidlogger(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) static voidmapCopy(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) Returns a duplicate copy of the source Mapstatic voidmapEntrySet(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) This handler returns theSetof entries for the givenMap.static voidmapGet(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) Returns the value to which the input map maps the input key.static voidmapJoin(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) static voidmapValueNullToFalse(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 voidmapValues(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) This handler returns theSetof keys for the givenMap.static voidprepareAlertMsg(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 voidprepareSuccessful(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) This method displays the save successful message when the page refresh.static voidresolveTokens(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) static voidroundTo2DecimalPoint(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) static voidserveResource(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext ctx) This handler serves a resource via JSFTemplating's FileStreamer.static voidstartsWith(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) This handler will test if a String starts with another String.
-
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.GregorianCalendaradd(int field, int amount).Input value: "Field" -- Type:
Integer-java.util.CalendarfieldInput 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:
StringOutput 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.FileOutput 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.MapOutput 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.MapInput value: "Key" -- Type:
ObjectOutput 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.MapInput 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.MapOutput 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
ListInput list: "list" -- Type:
java.util.ListInput value: "value" -- Type:
java.lang.ObjectInput 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 presentListInput list: "list" -- Type:
java.util.ListInput 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
ListInput 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
Listby adding the object in the 2nd list to the first listInput value: "list" -- Type:
java.util.ListInput 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 stringInput value: "list" -- Type:
java.util.ListInput value: "testStr" -- Type:
StringOutput 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:
ObjectInput value: "obj2" -- Type:
ObjectOutput 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.StringInput value: "type" -- Type:
java.lang.StringInput 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:
IntegerStart index, default to Zero is not specifiedInput value: "end" -- Type:
IntegerEnd index.Input value: "varName" -- Type:
StringVariable 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
Setof entries for the givenMap. -
mapValues
public static void mapValues(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx) This handler returns the
Setof keys for the givenMap. -
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
-