public class UiUtility extends Object
Among purposes are message handling, updating UI components, date/time processing, exception handling.
Note behavior of corresponding
| Modifier and Type | Class and Description |
|---|---|
static class |
UiUtility.ErrorType
Enum to help distinguish and handle different type of errors.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
MESSAGE_SUMMARY_DELETE_FAIL |
static String |
MESSAGE_SUMMARY_ERROR |
static String |
MESSAGE_SUMMARY_SUCCESS |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
causedByPersistenceException(Throwable t)
The method determines whether the cause of the exception is a
PersistenceException or
not. |
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.
|
static void |
dismissErrorMessage()
Closes error dialog.
|
static <E extends Enum<E>> |
parseIntoEnum(String enumConstantName,
Class<E> enumClassToCheck)
The method tries to parse the string into an enum constant.
|
static LocalDateTime |
processUIDateTime(String inDateTime)
The method tries to parse the string using the following rules.
|
static Long |
processUILong(String longStr)
Return a number represented by the input string,
null if there was an error. |
static void |
showErrorMessage(String explanation)
Utility method used to display an error message to the user.
|
static void |
showErrorMessage(String explanation,
Throwable throwable)
Utility method used to display an error message to the user.
|
static void |
showErrorMessage(UiUtility.ErrorType errorType,
String details,
String stackTrace)
Utility method used to display an error message to the user.
|
static void |
showInfoMessage(String summary)
Utility method used to display an information message to the user after modified entity successfully.
|
static void |
showMessage(javax.faces.application.FacesMessage.Severity severity,
String summary,
String message)
Utility method used to display a message to the user
|
static void |
updateComponent(String componentId)
Utility method used to update component.
|
public static final String MESSAGE_SUMMARY_SUCCESS
public static final String MESSAGE_SUMMARY_ERROR
public static final String MESSAGE_SUMMARY_DELETE_FAIL
public static void showInfoMessage(String summary)
summary - Summary of the messagepublic static void showErrorMessage(String explanation)
explanation - the explanation of the messagepublic static void showErrorMessage(String explanation, Throwable throwable)
explanation - the explanation of the messagethrowable - causepublic static void showErrorMessage(UiUtility.ErrorType errorType, String details, String stackTrace)
errorType - type of errordetails - error detail message to displaystackTrace - stack trace if exception is occurredpublic static void dismissErrorMessage()
public static void showMessage(javax.faces.application.FacesMessage.Severity severity,
String summary,
String message)
severity - Severity of the messagesummary - Summary of the messagemessage - Detailed message contentspublic static void updateComponent(String componentId)
componentId - component idpublic static boolean causedByPersistenceException(Throwable t)
PersistenceException or
not.t - - the exception to inspecttrue if the cause of the exception is javax.persistence.PersistenceException,
false otherwise.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.
t - the exception to inspectcause - the cause Exception type to test fortrue if the cause of the exception is cause Class, false
otherwise.public static LocalDateTime processUIDateTime(String inDateTime)
inDateTime - the user input we're trying to parse into date and timepublic static Long processUILong(String longStr)
null if there was an error.longStr - the string to parsenull if there was an errorpublic static <E extends Enum<E>> E parseIntoEnum(String enumConstantName, Class<E> enumClassToCheck)
E - the enumeration to check forenumConstantName - the enum constant name we're trying to parseenumClassToCheck - the enum class that we're trying to constructnull otherwise.Copyright © 2025 European Spallation Source. All rights reserved.