2 Replies Latest reply on Nov 8, 2013 8:30 AM by Jan Dosoudil

    Warp observe filtering by request params

    Jan Dosoudil Newbie

      Hi,

      I have JSF page with asynchronous form submitting (AJAX which saves component sizes based on browser size) and user action submitting (with <f:ajax>). I need to observe on user actions and ignore asynchronous requests. There are problems that all requests are AJAX POST to same URL with same headers and number of asynchronous requests changes so index filtering doesn't works. I can distinguish between them by request params but I didn't found way to do it in HttpFilters.request(). There may be similar problem with autocomplete box, key press events and so on.

       

      Is there any solution for request params filtering?

        • 1. Re: Warp observe filtering by request params
          Lukáš Fryč Master

          Hey Jan!

           

          If it would be GET request, you can use HttpRequestFilter and retrieve its URL.

          (Note: HttpFilters.request() is just builder for a RequestObserver of type HttpRequestFilter.)

           

          But since it is POST request, it has FormData encoded into its content.

           

          So that's I believe you hit a deficiency of request builder observer API!

           

          I have opened an issue to track it:

          [ARQ-1562] Warp: doesn't provide a built-in support for matching GET/POST requests by their parameters - JBoss Issue Tra…

           

          ----

           

          What's a workaround?

           

          Warp
              .initiate(activity)
              .observe(new HttpRequestFilter() {
          
          
                  public boolean matches(HttpRequest request) {
          
                      org.jboss.netty.handler.codec.http.HttpRequest nettyRequest = ((HttpRequestWrapper) request).unwrap();
                      ChannelBuffer content = nettyRequest.getContent();
                      
                      byte[] data = new byte[content.readableBytes()];
                      content.readBytes(data);
                      
                      String formData = new String(data);
                      
                      Map<String, String> httpPostParameters = parse(formData);
                  }
              })
              .inspect(inspection);
          

           

          I know it's rather complex, but I will make sure to get it into the Warp core in closest release.

          • 2. Re: Warp observe filtering by request params
            Jan Dosoudil Newbie

            Hi Lukáš,

            thanks a lot. I've tried implementing own HttpRequestFilter but unsuccessfully. Cast and unwrap hits what I've missed.