added validationFailed support

This commit is contained in:
2020-02-26 23:08:16 +01:00
parent 9090b2c66e
commit e12127f6dd

View File

@ -31,22 +31,18 @@ public abstract class FacesUtil {
}
/**
* returns true, if the current request is in the request phase. False
* otherwise.
* returns true, if the current request is in the request phase. False otherwise.
*
* @return true, if the current request is in the request phase. False
* otherwise.
* @return true, if the current request is in the request phase. False otherwise.
*/
public static boolean isRenderRequest() {
return !FacesContext.getCurrentInstance().getRenderResponse();
}
/**
* returns true, if the current request is in the response phase. True
* otherwise.
* returns true, if the current request is in the response phase. True otherwise.
*
* @return true, if the current request is in the response phase. True
* otherwise.
* @return true, if the current request is in the response phase. True otherwise.
*/
public static boolean isRenderResponse() {
return FacesContext.getCurrentInstance().getRenderResponse();
@ -56,8 +52,7 @@ public abstract class FacesUtil {
* Adds the given message to the "messages" object
*
* @param message the message to display
* @deprecated use addMessage(clientId, message) or
* addGlobalMessage(message) instead
* @deprecated use addMessage(clientId, message) or addGlobalMessage(message) instead
*/
@Deprecated
public static void addMessage(FacesMessage message) {
@ -142,8 +137,22 @@ public abstract class FacesUtil {
* @param detail the detailed message to display
*/
public static void addGlobalErrorMessage(String summary, String detail) {
addGlobalErrorMessage(summary, detail, false);
}
/**
* Adds the given message as global message with severity "Error".
*
* @param summary the summary message to display
* @param detail the detailed message to display
* @param valiationFailed if set to true, the method calls currentInstance().validationFailed() to invalidate the current request.
*/
public static void addGlobalErrorMessage(String summary, String detail, boolean valiationFailed) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, summary, detail);
FacesContext.getCurrentInstance().addMessage(null, message);
if (valiationFailed) {
FacesContext.getCurrentInstance().validationFailed();
}
}
/**
@ -168,12 +177,10 @@ public abstract class FacesUtil {
}
/**
* Adds the given message to the object with id "messages" and severity
* "Information".
* Adds the given message to the object with id "messages" and severity "Information".
*
* @param summary the message to display
* @deprecated use addInfoMessage(clientId, summary) or addGlobalInfoMessage
* instead
* @deprecated use addInfoMessage(clientId, summary) or addGlobalInfoMessage instead
*/
@Deprecated
public static void addInfoMessage(String summary) {
@ -181,13 +188,11 @@ public abstract class FacesUtil {
}
/**
* Adds the given message to the object with id "messages" and severity
* "Information".
* Adds the given message to the object with id "messages" and severity "Information".
*
* @param summary the summary message to display
* @param detail the detailed message to display
* @deprecated use addInfoMessage (clientId, summary, detail) or
* addGlobalInfoMessage(summary, detail) instead
* @deprecated use addInfoMessage (clientId, summary, detail) or addGlobalInfoMessage(summary, detail) instead
*/
@Deprecated
public static void addInfoMessage(String summary, String detail) {
@ -195,8 +200,7 @@ public abstract class FacesUtil {
}
/**
* Adds the given message with severity "Info" to the object with the id
* specified by clientId.
* Adds the given message with severity "Info" to the object with the id specified by clientId.
*
* @param clientId the id of the object to bind the message to.
* @param summary the summary message to display
@ -208,12 +212,10 @@ public abstract class FacesUtil {
}
/**
* Adds the given message to the object with id "warnings" and severity
* "Error".
* Adds the given message to the object with id "warnings" and severity "Error".
*
* @param summary the message to display
* @deprecated use addErrorMessage (clientId, summary, detail) or
* addGlobalErrorMessage(summary, detail) instead
* @deprecated use addErrorMessage (clientId, summary, detail) or addGlobalErrorMessage(summary, detail) instead
*/
@Deprecated
public static void addErrorMessage(String summary) {
@ -221,14 +223,12 @@ public abstract class FacesUtil {
}
/**
* Adds the given message to the object with id "warnings" and severity
* "Error".
* Adds the given message to the object with id "warnings" and severity "Error".
*
*
* @param summary the summary message to display
* @param detail the detailed message to display
* @deprecated use addErrorMessage (clientId, summary, detail) or
* addGlobalErrorMessage(summary, detail) instead
* @deprecated use addErrorMessage (clientId, summary, detail) or addGlobalErrorMessage(summary, detail) instead
*/
@Deprecated
public static void addErrorMessage(String summary, String detail) {
@ -236,8 +236,7 @@ public abstract class FacesUtil {
}
/**
* Adds the given message with severity "Error" to the object with the id
* specified by clientId.
* Adds the given message with severity "Error" to the object with the id specified by clientId.
*
* @param clientId the id of the object to bind the message to.
* @param summary the summary message to display
@ -249,12 +248,10 @@ public abstract class FacesUtil {
}
/**
* Adds the given message to the object with id "warnings" and severity
* "Warning".
* Adds the given message to the object with id "warnings" and severity "Warning".
*
* @param summary the message to display
* @deprecated use addWarningMessage (clientId, summary, detail) or
* addGlobalWarningMessage(summary, detail) instead
* @deprecated use addWarningMessage (clientId, summary, detail) or addGlobalWarningMessage(summary, detail) instead
*/
@Deprecated
public static void addWarningMessage(String summary) {
@ -262,13 +259,11 @@ public abstract class FacesUtil {
}
/**
* Adds the given message to the object with id "warnings" and severity
* "Warning".
* Adds the given message to the object with id "warnings" and severity "Warning".
*
* @param summary the summary message to display
* @param detail the detailed message to display
* @deprecated use addWarningMessage (clientId, summary, detail) or
* addGlobalWarningMessage(summary, detail) instead
* @deprecated use addWarningMessage (clientId, summary, detail) or addGlobalWarningMessage(summary, detail) instead
*/
@Deprecated
public static void addWarningMessage(String summary, String detail) {
@ -277,8 +272,7 @@ public abstract class FacesUtil {
}
/**
* Adds the given message with severity "Warning" to the object with the id
* specified by clientId.
* Adds the given message with severity "Warning" to the object with the id specified by clientId.
*
* @param clientId the id of the object to bind the message to.
* @param summary the summary message to display
@ -290,13 +284,11 @@ public abstract class FacesUtil {
}
/**
* Adds the given message to the object with id "warnings" and severity
* "Fatal".
* Adds the given message to the object with id "warnings" and severity "Fatal".
*
* @param summary the summary message to display
* @param detail the detailed message to display
* @deprecated use addFatalMessage (clientId, summary, detail) or
* addGlobalFatalMessage(summary, detail) instead
* @deprecated use addFatalMessage (clientId, summary, detail) or addGlobalFatalMessage(summary, detail) instead
*/
@Deprecated
public static void addFatalMessage(String summary, String detail) {
@ -305,8 +297,7 @@ public abstract class FacesUtil {
}
/**
* Adds the given message with severity "Fatal" to the object with the id
* specified by clientId.
* Adds the given message with severity "Fatal" to the object with the id specified by clientId.
*
* @param clientId the id of the object to bind the message to.
* @param summary the summary message to display