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