I have a viewScoped bean which has some business logic validation.
I display the resultant errors from this validation to the page using
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, result, null));
The problem is:
- user submits invalid form
- form redisplayed, messages not displayed to user due to using PRG
I solved this using the following line of code:
FacesContext.getCurrentInstance().getExternalContext().getFlash().setKeepMessages(true);
Now the problem is that the business logic validation messages persist too long:
- user submits invalid form
- form redisplayed with error messages
- user corrects and submits valid form
- form redisplayed with "success" message, but also previous error messages also displayed.
How can I fix this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…