Two days I'm looking for a solution to that basic problem. And YES I do have GETTER AND SETTER, and YES I really think that the convention is OK.
Here is the code :
Bean :
@Named
@SessionScoped
public class ClientController implements Serializable {
@Inject
private ClientService das;
private List<Client> clientsList;
public void setClientsList(List<Client> clientsList) {
this.clientsList = clientsList;
}
private Client client = new Client();
public Client getClient() {
return client;
}
public void setClient(Client client) {
this.client = client;
}
public void createclient(ActionEvent actionEvent) {
das.create(client);
}
public List<Client> getClientsList() {
clientsList = das.findByNativeQuery(Client.ALL);
return clientsList;
}
}
Page index.xhtml :
<ui:composition template="/templates/layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<ui:define name="content">
<h:form>
<p:panel header="Créer un Client">
<h:outputText value="Prénom : "></h:outputText>
<p:inputText id="clientName" value="#{clientController.client.name}" required="true"
requiredMessage="Entrez votre prénom" message="fc">
<f:validateLength minimum="2" />
</p:inputText>
<h:outputText value="Nom : "></h:outputText>
<p:inputText id="clientLastName" value="#{clientController.client.lastName}"
required="true" requiredMessage="Entrez votre nom" message="fc">
<f:validateLength minimum="2" />
</p:inputText>
</p:panel>
<p:commandButton value="Submit"
actionListener="#{clientController.createclient}" />
</h:form>
</ui:define>
</ui:composition>
Error :
/index.xhtml @14,57 value="#{clientController.client.name}": The class 'controllers.ClientController' does not have the property 'client'.
As you can see, the Bean is resolved, and even the createclient() method is resolved (I tried to test it without the rest of the code). The problem is just about attributes...
Please help ? I'm sure it's a stupid problem, but sometimes we just need an other point of view
EDIT:
WEB-INF/web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Bourse</display-name>
<!-- Current project stage. When it is set to 'Development' Primefaces give
a lot of debug information on the screen. -->
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>facelets.SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<welcome-file-list>
<welcome-file>/index.xhtml</welcome-file>
</welcome-file-list>
<!-- Staring JSF -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- JSF URL mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/manage-beans.xml</param-value>
</context-param>
</web-app>
WEB-INF/manage-beans.xml :
<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<managed-bean>
<managed-bean-name>clientController</managed-bean-name>
<managed-bean-class>controllers.ClientController</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>