Skip navigation links
org.openepics.cable.util

Class UiUtility

    • Method Detail

      • showInfoMessage

        public static void showInfoMessage(String summary)
        Utility method used to display an information message to the user after modified entity successfully.
        Parameters:
        summary - Summary of the message
      • showErrorMessage

        public static void showErrorMessage(String explanation)
        Utility method used to display an error message to the user.
        Parameters:
        explanation - the explanation of the message
      • showErrorMessage

        public static void showErrorMessage(String explanation,
                                            Throwable throwable)
        Utility method used to display an error message to the user.
        Parameters:
        explanation - the explanation of the message
        throwable - cause
      • showErrorMessage

        public static void showErrorMessage(UiUtility.ErrorType errorType,
                                            String details,
                                            String stackTrace)
        Utility method used to display an error message to the user.
        Parameters:
        errorType - type of error
        details - error detail message to display
        stackTrace - stack trace if exception is occurred
      • dismissErrorMessage

        public static void dismissErrorMessage()
        Closes error dialog.
      • showMessage

        public static void showMessage(javax.faces.application.FacesMessage.Severity severity,
                                       String summary,
                                       String message)
        Utility method used to display a message to the user
        Parameters:
        severity - Severity of the message
        summary - Summary of the message
        message - Detailed message contents
      • updateComponent

        public static void updateComponent(String componentId)
        Utility method used to update component.
        Parameters:
        componentId - component id
      • causedByPersistenceException

        public static boolean causedByPersistenceException(Throwable t)
        The method determines whether the cause of the exception is a PersistenceException or not.
        Parameters:
        t - - the exception to inspect
        Returns:
        true if the cause of the exception is javax.persistence.PersistenceException, false otherwise.
      • causedBySpecifiedExceptionClass

        public static boolean causedBySpecifiedExceptionClass(Throwable t,
                                                              Class<? extends Exception> cause)

        The method determines whether the cause of the exception is an exception of a specified class or not.

        Please note that the cause must explicitly be the exception class you are looking for, the method will not work for descendants of that class.

        Parameters:
        t - the exception to inspect
        cause - the cause Exception type to test for
        Returns:
        true if the cause of the exception is cause Class, false otherwise.
      • processUIDateTime

        public static LocalDateTime processUIDateTime(String inDateTime)
        The method tries to parse the string using the following rules. If input contains
        1. illegal characters (legal: [0-9\-: ]) then 1970-01-01 at midnight is assumed
        2. a number less than current date (day number in month), the day of this month is assumed
        3. a number (XX) above current day (date) and under the number of days of previous month, the day of previous month is assumed
        4. a number above the valid day number (see previous two lines) and below 99, the first day of 19XX or 20XX is assumed (depending on current year; 20XX will start after 2032)
        5. a number above 1900, then the first day of that year is assumed
        6. start of a date yyyy-m or yyyy-m-d, then start of the input year is assumed. In this case the year must be above 1900 and month and day must be correct.
        7. start of an hour (HH:m or HH:m:s) then the current day is assumed. 24 hour format.
        8. the "time" can be preceded by "date". They are separated by a space character
        The returned string is normalized to be parse-able by the standard formatter.
        Parameters:
        inDateTime - the user input we're trying to parse into date and time
        Returns:
        date time string represented by the input, or today at midnight if input is invalid.
      • processUILong

        public static Long processUILong(String longStr)
        Return a number represented by the input string, null if there was an error.
        Parameters:
        longStr - the string to parse
        Returns:
        a number represented by the input string, null if there was an error
      • parseIntoEnum

        public static <E extends Enum<E>> E parseIntoEnum(String enumConstantName,
                                                          Class<E> enumClassToCheck)
        The method tries to parse the string into an enum constant.
        Type Parameters:
        E - the enumeration to check for
        Parameters:
        enumConstantName - the enum constant name we're trying to parse
        enumClassToCheck - the enum class that we're trying to construct
        Returns:
        The enum constant E if successfully parsed, null otherwise.

Copyright © 2025 European Spallation Source. All rights reserved.