When a face message is added during a validation error, will the JSF skip application-application phase?

I need your help to understand this better. It's my business. I have a special validator for each of my input controls on the form. Therefore, when there is any validation error, I add the appropriate FacesMessage method to the validation method. My understanding was that when there is any validation error - or when there are any FacesMessages added in the user validator authentication method, it skips the INVOKE APPLICATION phase and directly calls the RENDER RESPONSE PHASE phase - showing the FacesMessage that was added In PROCESS VALIDATION Phase - is this correct?

The problem I am facing is adding FacesMessage to the PROCESS VALIDATION phase - due to a validation error - and I am adding a confirmation message for the action taken by the user in the INVOKE APPLICATION PHASES. Now both are shown on the page in the RENDER RESPONSE phase? - If my understanding is correct in the above question, is it best practice to conditionally add FacesMessage confirmation after confirming the absence of FacesMessages in currect FacesContext?

Here's how the message is added:

FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR,Constants.invalidMessageDetail,null);
         FacesContext.getCurrentInstance().addMessage(null, facesMessage);
throw new ValidatorException(facesMessage);

This is how it is shown:

<h:messages errorClass="ErrorMsg" warnClass="WarningMsg" infoClass="InfoMsg" layout="table"  />

Appreciate your help.

+3
source share
1 answer

, - - - FacesMessages, , INVOKE APPLICATION RENDER RESPONSE PHASE - FacesMessage, PROCESS VALIDATION - ?

. , ValidatorException , FacesMessage FacesContext.

- FacesMessage , currect FacesContext FacesMessages?

ValidatorException :

public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
    if (value does not meet conditions) {
        throw new ValidatorException(new FacesMessage("value does not meet conditions"));
    }
}

. , . JSF , ValidatorException.

+7

Source: https://habr.com/ru/post/1747964/


All Articles