View Javadoc

1   package net.sf.cantina.webgui;
2   
3   import org.apache.struts.action.Action;
4   
5   import javax.servlet.http.HttpServletRequest;
6   
7   import net.sf.cantina.Document;
8   import net.sf.cantina.ListIterator;
9   
10  /***
11   * @author Stephane JAIS
12   */
13  public abstract class StrutsAction
14  extends Action
15  {
16    public static final String DOCUMENT_KEY = "_document";
17    public static final String REALM_KEY = "_realm";
18    public static final String LIST_ITERATOR_KEY = "_listIterator";
19    public static final String MAPPING_SUCCESS = "success";
20    public static final String MAPPING_INPUT = "input";
21  
22    /***
23     * Saves the document and its realm as request attributes
24     * available to JSP pages.
25     * @param r The request
26     * @param d The Document
27     */
28  
29    public static void saveInRequest(HttpServletRequest r,Document d)
30    {
31      r.setAttribute(DOCUMENT_KEY,d);
32      r.setAttribute(REALM_KEY,d.getRealm());
33    }
34  
35    /***
36     * Saves the given ListIterator as a session attribute available
37     * to JSP pages.
38     * @param r The request
39     * @param l The iterator
40     */
41    
42    public static void saveInSession(HttpServletRequest r,ListIterator l)
43    {
44      r.getSession().setAttribute(LIST_ITERATOR_KEY,l);
45    }
46  }