bonjour tous le monde;
j'ai une formulaire jsf contient plusieurs champs, et je souhaite remplir le champ(réf facture) par une valeur récupérer a partir d'une liste des factures dans un autre page;
maintenant j'ai réussis de récupérer la valeur a partir la liste des factures,voilà mon code:
1) managedBean(mabean7):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
private String value1;
public String getValue1() {
return value1;
}
public void setValue1(String value1) {
this.value1 = value1;
}
public void action(ActionEvent event){
String value1 = (String)event.getComponent().getAttributes().get("attribute1");
this.value1 = value1;
}
public String gotoDetailFacture(){
return "newjsf.xhtml";
} |
2) page listeFacture.xhtml:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
</p:dataTable>
<p:dataTable value="#{mabean7.ALL}" var="item">
<p:column>
<f:facet name="header">
<h:outputText value="Réf Facture"/>
</f:facet>
<h:outputText value="#{item.refFact}"/>
</p:column>
//autre column
<p:column>
<f:facet name="header"></f:facet>
<h:commandButton value="select" action="#{mabean7.gotoDetailFacture}" actionListener="#{mabean7.action}">
<f:attribute name="attribute1" value="#{item.refFact}"/>
</h:commandButton>
</p:column>
</p:dataTable> |
3) page newjsf.xhtml:
1 2 3 4 5 6 7 8 9 10 11 12
|
<f:view>
<h:form>
<h:outputLabel value="Réf facture:" for="facture" />
<h:inputText id="facture" value="#{mabean7.value1}"/>
//d'autre champs
<h:commandButton value="Create" action="#{mabean6.CreateDetail}" type="submit"/>
</h:form>
</f:view> |
4) voila ma méthode de create:
1 2 3 4 5 6
| public Detailfacture createDetail(Detailfacture detailfacture) throws Exception {
em.persist(detailfacture);
return detailfacture;
} |
le problème quand je clique sur le bouton Create une errure s'affiche
Caused by: java.lang.IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST: JPA.Facture[refFact=null].
svp,comment résoudre ce problème
Partager