Class GuiUtil


  • public class GuiUtil
    extends Object
    Author:
    anilam - created on August 10, 2006, 9:19 PM
    • Constructor Detail

      • GuiUtil

        public GuiUtil()
        Creates a new instance of GuiUtil
    • Method Detail

      • getLogger

        public static Logger getLogger()
      • guiLog

        public static void guiLog​(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
      • isEmpty

        public static boolean isEmpty​(String str)
      • getCommonMessage

        public static String getCommonMessage​(String key,
                                              Object[] args)
      • initSessionAttributes

        public static void initSessionAttributes()
      • setSessionValue

        public static void setSessionValue​(String key,
                                           Object value)
      • getSessionValue

        public static Object getSessionValue​(String key)
      • encode

        public static String encode​(String value,
                                    String delim,
                                    String type)

        This method encodes the given String with the specified type.

        If type is not specified then it defaults to UTF-8.

        Parameters:
        value - String to be encoded
        delim - Reserved Characters don't want to be encoded
        type - Encoding type. Default is UTF-8
      • genId

        public static String genId​(String uid)

        This method generates an ID that is safe for JSF for the given String. It does not guarantee that the id is unique, it is the responsibility of the caller to pass in a String that will result in a UID. All non-ascii characters will be replaced with an '_'. This method will also ensure an alpha character (or '_') is the first character in the id.

        Parameters:
        uid - A non-null String.
      • getMessage

        public static String getMessage​(String key)
        returns the strings from org.glassfish.admingui.core.Strings if no such key exists, return the key itself.
      • getCommonMessage

        public static String getCommonMessage​(String key)
      • getLocale

        public static Locale getLocale()
      • prepareSuccessful

        public static void prepareSuccessful​(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
        This method sets up the attributes of the message box so that a saved sucessfully message will be displayed during refresh.
      • prepareException

        public static void prepareException​(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx,
                                            Throwable ex)
        This method sets up the attributes of the message box. It is similar to handleException without calling renderResponse()
      • prepareAlert

        public static void prepareAlert​(String type,
                                        String summary,
                                        String detail)
        This method sets up the attributes of the message box so that any alert message of any type will be displayed during refresh. If type is not specified, it will be "information" by default.
      • handleException

        public static void handleException​(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx,
                                           Throwable ex)
      • handleError

        public static void handleError​(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx,
                                       String detail)
      • notNull

        public static String notNull​(String test)
        This method ensure that there will not be a NULL String for the passed in object.
      • convertListOfStrings

        public static List<String> convertListOfStrings​(List l)
      • parseStringList

        public static List<String> parseStringList​(String line,
                                                   String sep)
        Parses a string containing substrings separated from each other by the specified set of separator characters and returns a list of strings. Splits the string line into individual string elements separated by the field separators specified in sep, and returns these individual strings as a list of strings. The individual string elements are trimmed of leading and trailing whitespace. Only non-empty strings are returned in the list.
        Parameters:
        line - The string to split
        sep - The list of separators to use for determining where the string should be split. If null, then the standard separators (see StringTokenizer javadocs) are used.
        Returns:
        Returns the list containing the individual strings that the input string was split into.
      • stringToArray

        public static String[] stringToArray​(String str,
                                             String delimiter)
        This method converts a string into stringarray, uses the delimeter as the separator character. If the delimiter is null, uses space as default.
      • arrayToString

        public static String arrayToString​(String[] str,
                                           String delimiter)
        This method concatenates the delimiter char to the end of each string in the array, and returns a single string with the concatenated string.
      • asArray

        public static <T> T[] asArray​(Object o)
      • isSelected

        public static boolean isSelected​(String name,
                                         List<Map<String,​?>> selectedList)
      • checkEmpty

        public static String checkEmpty​(String test)
      • getHabitat

        public static org.glassfish.hk2.api.ServiceLocator getHabitat()
      • getCauses

        public static Throwable[] getCauses​(Throwable start)
        Get the chain of exceptions via getCause(). The first element is the Exception passed.
        Parameters:
        start - the Exception to traverse
        Returns:
        a Throwable[] or an Exception[] as appropriate
      • getRootCause

        public static Throwable getRootCause​(Throwable e)
        Get the original troublemaker.
        Parameters:
        e - the Exception to dig into
        Returns:
        the original Throwable that started the problem
      • tryToFindOriginalErrorMessage

        public static String tryToFindOriginalErrorMessage​(Object entity)