I've got a managed bean implemented through CDI, which as i've read is the recommended way to implement it, and is declared like this:
import javax.inject.Named;
import javax.faces.view.ViewScoped;
@Named
@ViewScoped
public class ConsultaGeneralController implements Serializable {
Besides, I have a JSP which is in charged of displaying the contents of the bean. As a side note I know JSF and JSP should'nt be used together as they are not compatible out of the box in the latest releases, but where i am working on there are some jsp's files that need to be included in every system and those haven't been migrated to xhtml and refactoring them currently is not posible.
Now, in the JSP i have the following button:
<h:commandButton action="#{consultaGeneralController.listData()}" value="Buscar"> </h:commandButton>
When i press it, the web page is reloaded, no method is executed, not even the method marked as @PostConstruct.
But debugging when i comment this section of code:
<h:selectOneMenu styleClass="form-control" value="#{consultaGeneralController.bancoOrigenS}">
<f:selectItems value="#{consultaGeneralController.listaBancos}" />
</h:selectOneMenu>
Specifically:
<f:selectItems value="#{consultaGeneralController.listaBancos}" />
And changing it for a:
<f:selectItem itemValue = "test" itemLabel = "test" />
The method is indeed executed.
Just in case it helps the method is this (Just testing) :
public void listData() {
System.out.println("Hi test");
System.out.println(fechaDesde + " " + fechaHasta);
}
I've also teste others scopes for the bean, in case it was the cause, i've tested SessionScope, ConversationScope and RequestScope(Which causes the PostConstruct method to be executed after i press it)