View Javadoc

1   package org.sourceforge.vlibrary.user.actions;
2   
3   
4   import java.util.ArrayList;
5   
6   import javax.servlet.http.HttpServletRequest;
7   import javax.servlet.http.HttpServletResponse;
8   
9   import org.apache.log4j.Logger;
10  import org.apache.struts.action.ActionForm;
11  import org.apache.struts.action.ActionForward;
12  import org.apache.struts.action.ActionMapping;
13  import org.apache.struts.util.MessageResources;
14  import org.sourceforge.vlibrary.exceptions.LibraryException;
15  import org.sourceforge.vlibrary.user.forms.BookSearchForm;
16  
17  /**
18   * Loads subject list to prepare book search action
19   * @version $Revision$ $Date$
20   */
21  public class PrepareListBookAction extends LibraryAction {
22  
23      /** log4j Logger */
24      private static Logger logger =
25       Logger.getLogger(PrepareListBookAction.class.getName());
26  
27      /**
28       * Prepare Book List Action implementation -- loads Subject and location lists.
29       *
30       * @param mapping The ActionMapping used to select this instance
31       * @param form The optional ActionForm bean for this request (if any)
32       * @param request The HTTP request we are processing
33       * @param response The HTTP response we are creating
34       * @param messages message resources
35       *
36       * @exception Exception
37       */
38      public ActionForward executeAction(ActionMapping mapping,
39       ActionForm form,
40       HttpServletRequest request,
41       HttpServletResponse response,
42       MessageResources messages)
43       throws Exception {
44  
45          BookSearchForm frm = (BookSearchForm) form;
46          ArrayList<LibraryException> errors = new ArrayList<LibraryException>();
47  
48          // load subjectList
49          try {
50              frm.setSubjectList(libraryManager.getSubjects());
51          } catch (Throwable t) {
52              String errString = messages.getMessage("error.subjects.retrieve");
53              logger.error(errString,t);
54              errors.add(new LibraryException(errString,t));
55          }
56  
57          // load locations
58          try {
59              frm.setLocations(libraryManager.getLocations());
60          } catch (Throwable t) {
61              String errString = messages.getMessage("error.locations.retrieve");
62              logger.error(errString,t);
63              errors.add(new LibraryException(errString,t));
64          }
65  
66          return standardForward(mapping,request,errors);
67      }
68  }