2 Replies Latest reply on Sep 8, 2008 11:28 AM by demetrio812

    Seam resource problem

    demetrio812 Apprentice

      Hi,
      according to this document, I made the following Resource class that works perfectly:


      @Scope(ScopeType.APPLICATION)
      @Name("imageDelivery")
      @BypassInterceptors
      public class ImageDelivery extends AbstractResource {
          /**
           * The maximum width allowed for image rescaling
           */
          private static final int MAX_IMAGE_WIDTH = 1024;
         
          @Override
          public String getResourcePath() {
              return "/imageDelivery";
          }
          
          @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) throws IOException {
          }
      }
      



      Then I had to call a Seam component called uiOptions that looks like this:



      @Name("uiOptions")
      @Scope(ScopeType.CONVERSATION) 
      @Synchronized
      public class UIOptions {
      
           @In FacesContext facesContext;
           
           ...etc...
      }
      


      I get the component from the doWork method using this code:



      UIOptions uiOptions = (UIOptions) Component.getInstance("uiOptions", true);




      The problem is that when I call some method of uiOptions that use facesContext it give me the following error:



      org.jboss.seam.RequiredException: @In attribute requires non-null value: uiOptions.facesContext



      so facesContext doesn't exists (is null) on injecting from a resource call, if I use uiOptions in the normal way (for example inside XHTML) it works perfectly...


      Any idea on how to make it works?


      Thanks a lot!


      Demetrio Filocamo
      (filocamo@demetrio.it)