4 Replies Latest reply on Mar 16, 2009 4:23 PM by Francois Eric

    RequestParameter from AbstractResource

    Francois Eric Novice

      Hi,


      I'm trying to access a request parameter from my resource but don't know how...


      here is an example of url:


      http://localhost:8080/seam/resource/importation?startDate=2009-01-01&endDate=2009-01-31
      



      and here is my code:


      @Scope(ScopeType.APPLICATION)
      @Name("importationResource")
      @BypassInterceptors
      public class ImportationResource extends AbstractResource {
      
          @Override
          public String getResourcePath() {
              return "/importation";
          }
          
          @RequestParameter 
          String startDate;
          
          @RequestParameter 
          String endDate;
      
          @Override
          public void getResource(final HttpServletRequest request, final HttpServletResponse response)
                  throws ServletException, IOException {
      
              new ContextualHttpServletRequest(request) {
                  @Override
                  public void process() throws IOException {
                      doWork(request, response);
                  }
              }.run();
          }
      
          private void doWork(HttpServletRequest request, HttpServletResponse response) {
              try {
                  ImportationAction importation = (ImportationAction) Component.getInstance(ImportationActionImpl.class);
                  
                  Date startDateValue = startDate != null ? DateManipulations.getInstance().ISO_DATE_FORMAT.parse(startDate) : null;
                  Date endDateValue = endDate != null ? DateManipulations.getInstance().ISO_DATE_FORMAT.parse(endDate) : null;
                  importation.importDailyData(startDateValue, endDateValue);
                  
                  response.getWriter().write("Ok");
              } catch (Exception e) {
                  try {
                      e.printStackTrace(response.getWriter());
                  } catch (IOException e1) {
                      //Do nothing
                  }
              }
          }
      }
      
      



      Unfortunately, when I debug I notice that startDate and endDate are always null.  How can I get them otherwise?


      Thanks,


      François