3 Replies Latest reply on Jul 23, 2007 12:16 PM by Jonas Buechel

    weblets similar fuctionality in seam?

    Jonas Buechel Novice

      Just a short question (although i did a quite long research in forums):

      Is there a weblets similar functionality in JBoss Seam or a4j?
      I'm on the verge of including weblets to my project but i'm not very happy about including another library and configuration stuff..

      Information would be very appriciated.

        • 1. Re: weblets similar fuctionality in seam?
          Norman Richards Master

          Take a look at the Seam Resource Servlet. It doesn't work exactly like weblets, but it solves a very similar problem.

          • 2. Re: weblets similar fuctionality in seam?
            Jonas Buechel Novice

            Thanks for the hint, Norman!

            It's quite simple and pretty much that what i was looking for.

            Here is some code for interested ones:

            @Startup
            @Scope(ScopeType.APPLICATION)
            @Name("fwcResource")
            @Install(precedence = Install.BUILT_IN)
            @BypassInterceptors
            public class FwcResource extends AbstractResource {
            
             //Has to start with the url-pattern of Seam Resource Servlet mapping in web.xml
             public static final String WEB_RESOURCE_PATH = "/seam/resource/fwc";
             private static final String RESOURCE_PATH = "/fwc";
            
             @Override
             public String getResourcePath() {
            
             return RESOURCE_PATH;
             }
            
             @Override
             public void getResource(HttpServletRequest request,
             HttpServletResponse response) throws ServletException, IOException {
            
             String pathInfo = request.getPathInfo().substring(
             getResourcePath().length());
            
             InputStream in = Resources.getResourceAsStream(
             "/com/test" + pathInfo,
             getServletContext());
            
             if (in != null) {
             byte[] buffer = new byte[1024];
             int read = in.read(buffer);
             while (read != -1) {
             response.getOutputStream().write(buffer, 0, read);
             read = in.read(buffer);
             }
             response.getOutputStream().flush();
             } else {
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
             }
            
             }
            
            }
            


            • 3. Re: weblets similar fuctionality in seam?
              Jonas Buechel Novice

              Or just leave this constant if you don't need:

               //Has to start with the url-pattern of Seam Resource Servlet mapping in web.xml
               //public static final String WEB_RESOURCE_PATH = "/seam/resource/fwc";