I'm working and learning about JSF + Facelets these days. I have a BackingBean and a Facelet xHTML page. When I request the facelet-page (only one time) the backing-bean-method is called multiple times.
What could be the reason for this?
I can't see anything special. Thanks in advance.
Here is the facelet:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Insert title here</title> </head> <body> <ui:composition template="index.xhtml"> <ui:define name="content"> <h:form>Name: <h:inputText id="nameFilterPattern" value="#{kundenBackingBean.nameFilterPattern}" /><h:commandButton value="Suchen"/></h:form> <h:dataTable var="kunde" value="#{kundenBackingBean.kunden}" rowClasses="rowHighlight, rowOrdinary"> <h:column> <f:facet name="header"> <h:outputText value="Kundennr" /> </f:facet> <h:outputText value="#{kunde.kundenNr}"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="Name" /> </f:facet> <h:outputText value="#{kunde.name}"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="Vorname" /> </f:facet> <h:outputText value="#{kunde.vorname}"/> </h:column> <h:column> <h:outputLink>Details</h:outputLink> </h:column> </h:dataTable> </ui:define> </ui:composition> </body> </html> And here is the backing-bean. The method getKunden is called multiple times:
@ManagedBean @SessionScoped public class KundenBackingBean extends AbstractBackingBean { private String nameFilterPattern; public List<Kunde> getKunden(){ System.out.println("getKunden"); return getApplication().getKunden(getNameFilterPattern()); } public String getNameFilterPattern() { return nameFilterPattern; } public void setNameFilterPattern(String nameFilterPattern) { System.out.println("Name filter: " + nameFilterPattern); this.nameFilterPattern = nameFilterPattern; } }