interfaçage jsf1.2 et spring3
Bonjour,
J'utilise JSF 1.2, Spring 3.0.0 et Hibernate 3.2 dans uns projet avec une structure maven2.
Le projet est structuré en :
- Couche Controller
- Couche Service
- Couche DAO
j'ai configuré mon springContext pour que j'utilise les annotations Spring.
Le problème est lorsque je veux ajouter un nouvel enregistrement, une exception NullPointerException est levée m'indiquant que l'entité est nulle.
Code du Controller :
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
|
@Controller("myCtrl")
@Scope("request")
public class MyController {
private IMyService myService;
private MyEntity myEntity;
public IMyService getMyService(){
return myService;
}
@Autowired
public setMyService(IMyService myService){
this.myService = myService;
}
public IMyEntity getMyEntity(){
return myService;
}
public setMyEntity(IMyEntity myEntity){
this.myEntity = myEntity;
}
public String save(){
myService.add(myEntity);
return "consult";
}
} |
le add.xhtml :
Code:
1 2 3 4 5 6
|
<h:form>
<h:outputText value="nom" />
<h:inputText value="#{myCtrl.myEntity.nom}" />
<h:commandButton action="#{myCtrl.save}" value="add" />
</h:form> |
Quelqu'un a une idée sur ce problème ?
Merci de votre aide.