Reputation: 965
I want to style a cell of a table conditionally. This is easy and works.
style="#{zoekOndernemingController.geldigeOnderneming(row) ? '' : 'color: red'}"
However, the condition is on the backend as you can see. In the function geldigeOnderneming(Object o) I add a faces message, but this message is not displayed. Is it because there are restrictions when calling backend functions from certain attributes, like style?
I have no idea why it is not displayed, and I also don't know how to debug this. On the internet I cannot find anything about this so any help is greatly appreciated!
PS faces message added like this:
public static void addFacesMessage(final FacesMessage fm) {
final FacesContext ctx = JSFUtils.getFacesContextInstance();
ctx.addMessage(null, fm);
}
It works perfectly in other places...
Upvotes: 2
Views: 327
Reputation: 1108632
You're basically trying to add a faces message during render response. It will be too late if the message(s) component was already rendered for long at that point.
<h:messages />
...
<h:someComponent someAttribute="#{bean.someMethodWhichAddsMessage()}" />
It will "work" if you swap around the components.
Upvotes: 4