Global: Invalid state for inputs referenced from a FacesMessage via clientId
See original GitHub issueWe sometimes add errors to inputs via Java-business-logic:
FacesContext.getCurrentInstance().addMessage("form:txt", new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error!", "Contact admin."));
This come with the limitation, that this input does not get the same red border like inputs which have an validation-error.
The following generic code make setValid(false) to all input´s which have a error-message.
private void transferFacesErrors2NotValid() {
Spliterator<String> spliterator = Spliterators.spliteratorUnknownSize(FacesContext.getCurrentInstance().getClientIdsWithMessages(), 0);
StreamSupport.stream(spliterator, false).forEach(clientId -> {
long errors = FacesContext.getCurrentInstance().getMessageList(clientId).stream().filter(m -> m.getSeverity().equals(FacesMessage.SEVERITY_ERROR)).count();
if (errors>0) {
UIComponent uiComp = FacesContext.getCurrentInstance().getViewRoot().findComponent(clientId);
if (uiComp instanceof UIInput) {
((UIInput) uiComp).setValid(false);
}
}
});
}
By setting valid to false the inputs get the red border.
Is this something we may add in some way to PrimeFaces?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:14 (14 by maintainers)
Top Results From Across the Web
Getting the current global messages from FacesContext
When validation error messages are produced, the facelet works fine, because one of the messages tag has the globalOnly="true" ...
Read more >Primefaces Message, Messages & Growl components ...
Queuing messages require to pass through jsf lifecycle. ... false, String, When true, only facesmessages with no clientIds are displayed.
Read more >17 Displaying Tips, Messages, and Help - Oracle Help Center
This chapter describes how to define and display tips and messages for ADF Faces components, and how to provide different levels of help...
Read more >Component Reference - Red Hat on GitHub - JBoss.org
A reference guide to the components of the RichFaces 4 framework ... values from the input element and auxiliary information such as state-saving...
Read more >Multiple Messages for a Single Component - Cameron Gregor
A FacesMessage can either be 'Global', which means it has no relation to any ... either from Java using the FacesMessages class as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think we can add it with a config flag in 9.0 which is disabled per default
look good