View Javadoc

1   /***
2    * 
3    */
4   package net.trajano.twiff.internal.servlet;
5   
6   import java.lang.reflect.Method;
7   import javax.servlet.http.HttpServletRequest;
8   import net.trajano.twiff.AttachmentPageLookup;
9   import net.trajano.twiff.ViewServletConfiguration;
10  
11  /***
12   * Provides the logic to lookup data for action and attachements.
13   * 
14   * @author Archimedes Trajano
15   */
16  public class AttachmentActionPageLookup extends ViewPageLookup implements net.trajano.twiff.ActionPageLookup, AttachmentPageLookup {
17      /***
18       * Constructs the lookup.
19       * 
20       * @param configuration
21       *                   configuration.
22       */
23      public AttachmentActionPageLookup(final ViewServletConfiguration configuration) {
24          super(configuration);
25      }
26  
27      /***
28       * @throws ClassNotFoundException
29       * @see net.trajano.twiff.ActionPageLookup#getActionMethod(javax.servlet.http.HttpServletRequest)
30       */
31      public Method getActionMethod(final HttpServletRequest request) throws NoSuchMethodException, SecurityException, ClassNotFoundException {
32          return getPageBeanClass(request).getMethod(getActionMethodName(request));
33      }
34  
35      /***
36       * @see net.trajano.twiff.ActionPageLookup#getActionMethodName(javax.servlet.http.HttpServletRequest)
37       */
38      public String getActionMethodName(final HttpServletRequest request) {
39          String originalPageName = super.getPageName(request);
40          return originalPageName.substring(originalPageName.lastIndexOf('_') + 1);
41      }
42  
43      /***
44       * @see net.trajano.twiff.internal.servlet.ViewPageLookup#getPageName(javax.servlet.http.HttpServletRequest)
45       */
46      public String getPageName(final HttpServletRequest request) {
47          String originalPageName = super.getPageName(request);
48          return originalPageName.substring(0, originalPageName.lastIndexOf('_'));
49      }
50  
51      /***
52       * @see net.trajano.twiff.AttachmentPageLookup#getPropertyName(javax.servlet.http.HttpServletRequest)
53       */
54      public String getPropertyName(final HttpServletRequest request) {
55          return getActionMethodName(request);
56      }
57  }