[569] | 1 | /* |
---|
| 2 | * Created on 3 mai 2005 |
---|
| 3 | */ |
---|
| 4 | package com.medias.megapoli.struts.actions; |
---|
| 5 | |
---|
| 6 | import javax.servlet.ServletException; |
---|
| 7 | import javax.servlet.http.*; |
---|
| 8 | |
---|
| 9 | import org.apache.struts.action.*; |
---|
| 10 | import com.medias.megapoli.struts.forms.CapteurForm; |
---|
| 11 | import com.medias.megapoli.trade.CapteurAdapter; |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | /** |
---|
| 15 | * @author pignot |
---|
| 16 | * |
---|
| 17 | * Action déclenchée au moment d'afficher la description d'un capteur |
---|
| 18 | */ |
---|
| 19 | public class DescCapteurAction extends Action { |
---|
| 20 | |
---|
| 21 | public ActionForward execute (ActionMapping mapping, |
---|
| 22 | ActionForm form, |
---|
| 23 | HttpServletRequest request, |
---|
| 24 | HttpServletResponse response) |
---|
| 25 | throws ServletException { |
---|
| 26 | |
---|
| 27 | CapteurAdapter adapter = new CapteurAdapter (); |
---|
| 28 | String target = "failure"; |
---|
| 29 | ActionErrors errors = new ActionErrors (); |
---|
| 30 | |
---|
| 31 | if (form != null) { |
---|
| 32 | CapteurForm cform = (CapteurForm)form; |
---|
| 33 | String id = request.getParameter ("idCapt"); |
---|
| 34 | try { |
---|
| 35 | // A partir de la base de données ... |
---|
| 36 | adapter.loadCapteurFromDatabase (cform, id); |
---|
| 37 | target = "success"; |
---|
| 38 | } catch (Exception e) { |
---|
| 39 | System.out.println ("exception_DescCapteurAction"); |
---|
| 40 | errors.add (ActionErrors.GLOBAL_MESSAGE, |
---|
| 41 | new ActionError ("errors.access.requete.fail")); |
---|
| 42 | e.printStackTrace (); |
---|
| 43 | } |
---|
| 44 | } |
---|
| 45 | if (!errors.isEmpty ()) { |
---|
| 46 | saveErrors (request, errors); |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | return mapping.findForward (target); |
---|
| 50 | |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | } |
---|