problème insertion dans BDD
Bonjour à tous
ma page JSF
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Confirmation </title>
</head>
<body>
<h1>Validation</h1>
<f:view>
<h:form>
<h:panelGrid border="1" columns="2">
<h:outputText value="Nom:"></h:outputText>
<h:inputText id="firstName" required="true" value="#{Beans.nom}"/>
</h:panelGrid>
<h:commandButton value="Confirmer votre ajout" style="width: 183px" action="#{Beans.ajouterBase}"></h:commandButton>
</h:form>
</f:view>
</body>
</html> |
voici mon code bean:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Beans {
private String nom;
public String getNom() {
return nom;
}
public void nomAuteur(String nom){
this.nom = nom;
}
public String ajouterBase(){
Connection con= new BDD().getCon();
try {
Statement stmt=con.createStatement();
int val = stmt.executeUpdate("insert into ESSAIT (ID,NOM) values('3','"+ nom +"')");
} catch (SQLException e) {
e.printStackTrace();
}
return "retour";
}
} |
dans mon fichier face.config:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
<?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_1_2.xsd"
version="1.2">
<managed-bean>
<managed-bean-name>Beans</managed-bean-name>
<managed-bean-class>Beans</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config> |
mais j'ai l'erreur suivante:
Code:
1 2
|
sourceId=j_id_jsp_1959541834_1:firstName[severity=(ERROR 2), summary=(/qq.jsp(19,0) '#{Beans.nom}' Property 'nom' not writable on type java.lang.String), detail=(/qq.jsp(19,0) '#{Beans.nom}' Property 'nom' not writable on type java.lang.String)] |