Beans en request qui dissparait
Bonjour,
Je pense que ça vient d'une mauvaise compréhension de ma part, mais j'ai un souci tout bête.
J'ai un application qui va chercher des informations dans la base de données et qui permet soit d'en insérer soit de modifier celle existante.
Donc j'ai déclarer mon bean dans le face config:
Code:
1 2 3 4 5
| <managed-bean>
<managed-bean-name>PaysDataBeans</managed-bean-name>
<managed-bean-class>DataBeans.PaysDataBeans</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope></managed-bean>
<managed-bean> |
Pour l'insertion ça marche niquel:
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
| <?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:h="http://java.sun.com/jsf/html">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<h:panelGrid columns="2">
<h:column>
<h:outputLabel value="Code Iso Pays"/>
</h:column>
<h:column>
<h:inputText id="codeIsoPays" value="#{PaysDataBeans.codeIsoPays}"/>
</h:column>
<h:column>
<h:outputLabel value="Pays"/>
</h:column>
<h:column>
<h:inputText id="pays" value="#{PaysDataBeans.pays}"/>
</h:column>
</h:panelGrid>
<h:commandButton action="#{PaysController.inserer}" value="Ajouter"/>
</h:form>
</h:body>
</html> |
Par contre pour l'édition...
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
| <?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:h="http://java.sun.com/jsf/html">
<h:head>
<title>Facelet Title</title>
</h:head>
<h1> Editer pays </h1>
<h:body>
<h:form>
<h:panelGrid columns="2">
<h:column>
<h:outputLabel value="Code Iso Pays"/>
</h:column>
<h:column>
<h:inputText id="codeIsoPays" value="#{PaysDataBeans.codeIsoPays}" label="#{PaysController.crtSelected.codeIsoPays}"/>
</h:column>
<h:column>
<h:outputLabel value="Pays"/>
</h:column>
<h:column>
<h:inputText id="pays" value="#{PaysDataBeans.codeIsoPays}" label="#{PaysController.crtSelected.pays}"/>
</h:column>
</h:panelGrid>
<h:commandButton action="#{PaysController.update}" value="mettre a jour"/>
</h:form>
</h:body>
</html> |
Mais lorsque je fais
Code:
1 2 3 4 5 6 7 8
| public String update(){
//recuperation du nouveau bean en request
FacesContext fc = FacesContext.getCurrentInstance();
PaysDataBeans updatedPays = (PaysDataBeans) fc.getExternalContext().getRequestMap().get("PaysDataBeans");
worker.updatePays(crtSelected.getCodeIsoPays(),updatedPays);
return "ListePays";
} |
il me retourne null alors que dans la méthode insérer il récupère les informations sans souci.
Est-ce que quelqu'un sait d'où vient mon erreur?
Baltak