I need some light about something strange we have noticed in our project.
We have a Primefaces 10 (Omnifaces) + JSF 2 project and we see that when we click a button (or trigger an AJAX request) log shows a lot of DB queries. After tracing one of them I've seen that corresponds to a method referereced from a rendered attribute.
I've tried adding an outputText showing the system time and yes, the rendered method is executed, but the text does not get updated. I've noticed, also, that they are executed before the action method of the button, making it clearer that it's not about an update step (enclosing components do not use autoupdate, either).
I've tried enabling attributes like process="@this", partialSubmit="true", etc. unsuccessfully. Every time I click the button the rendered events are triggered.
Keeping apart the fact that each method is being launched several times, I don't understand why rendered methods are executed. They are a problem because some calculations are not immediate.
Is there something I am missing? Or, is there any way to switch off or restrict this behavior?
Thanks in advance.
EDIT:
I add some code. For the button and rendering element:
<h:outputText rendered="#{view.show_time()}" value="#{view.time()}" />
<p:commandButton value="Click!" action="#{view.action()}" />
For the Java backend:
public boolean show_time() {
//Breakpoint here. Should be triggered first.
System.out.println("rendered");
return true;
}
public long time() {
//Breakpoint here. Should not be triggered.
return System.currentTimeMillis();
}
public void action() {
//Breakpoint here. Should be triggered second.
System.out.println("action");
}
If you don't notice anything running this example its clearly something wrong or that I am missing in my project.