Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/fenceui/actions/FencerDetailAction.java


1   package org.fenceui.actions;
2   
3   import javax.servlet.http.HttpServletRequest;
4   import javax.servlet.http.HttpServletResponse;
5   import javax.servlet.http.HttpSession;
6   import org.apache.struts.action.Action;
7   import org.apache.struts.action.ActionForm;
8   import org.apache.struts.action.ActionForward;
9   import org.apache.struts.action.ActionMapping;
10  
11  import org.fenceui.beans.FencerList;
12  import org.fenceui.beans.CompetitionResultList;
13  import org.fenceui.forms.FencerDetailForm;
14  
15  import org.fencedb.logic.LogicFactory;
16  import org.fencedb.logic.ReadLogic;
17  import org.fencedb.logic.LogicException;
18  
19  // XXX fixme vico
20  import org.odmg.QueryException;
21  
22  import java.util.List;
23  
24  /**
25   *  Description of the Class
26   *
27   * @author  vico
28   * @created  June 11, 2003
29   */
30  public final class FencerDetailAction extends Action
31  {
32  
33      /**
34       *  Description of the Method
35       *
36       * @param  mapping Description of the Parameter
37       * @param  form Description of the Parameter
38       * @param  request Description of the Parameter
39       * @param  response Description of the Parameter
40       * @return  Description of the Return Value
41       */
42      public ActionForward perform(ActionMapping mapping,
43                                   ActionForm form,
44                                   HttpServletRequest request,
45                                   HttpServletResponse response)
46      {
47  
48          FencerDetailForm fdf = (FencerDetailForm)form;
49  
50          String id = fdf.getIndex();
51          int ix = Integer.parseInt(id);
52  
53          HttpSession session = request.getSession();
54          FencerList fencers = (FencerList)session.getAttribute("fencers");
55          if (fencers == null) {
56              request.setAttribute("errormessage", "error.nofencers");
57              return (mapping.findForward("error"));
58          }
59  
60          fencers.setIndex(ix);
61  
62          // fetch competition results for that fencer
63          CompetitionResultList participations = (CompetitionResultList)session.getAttribute("participations");
64          if (participations == null) {
65              List resultList = null;
66              try {
67                  resultList = fencers.getFencer().getCompetitionResults();
68              }
69              // XXX fixme vico
70              catch (QueryException qe) {
71                  qe.printStackTrace();
72              }
73              participations = new CompetitionResultList(resultList);
74          }
75          session.setAttribute("participations", participations);
76  
77          // Transfer the data from the fencers bean to the ActionForm
78          fdf.setIndex(id);
79          fdf.setLastName(fencers.getLastName());
80          fdf.setFirstName(fencers.getFirstName());
81          fdf.setCountry(fencers.getCountry());
82          fdf.setClub(fencers.getClub());
83          fdf.setBirthDate(fencers.getBirthDate());
84  
85          // Forward control to the detail page
86          return (mapping.findForward("fencerDetail"));
87      }
88  
89  }
90