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
|
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
AfficherProduitForm afficherProduitForm = (AfficherProduitForm) form;
try
{
// Creation du contexte pour l'ejb
Context c = new InitialContext();
Object ref = c.lookup("ejb/EjbAdmin");
Produit pr;
// Appel à l'ejb
EjbAdminHome h = (EjbAdminHome) PortableRemoteObject.narrow(ref,EjbAdminHome.class);
EjbAdmin bean = h.create();
Produit a = (Produit) request.getAttribute("produits");
System.out.println("a : " + a.getNomProduit());
pr = bean.afficherDetailProduit(a.getNomProduit());
afficherProduitForm.setDetailProduit(pr);
request.setAttribute("monProduit",pr);
return mapping.findForward("retourListeProduit");
}
catch(Exception e)
{
System.out.println("Erreur[AfficherProduitAction] : " + e);
afficherProduitForm.reset(mapping,request);
return mapping.findForward("annulationafficherProduitForm");
}
} |