4 Replies Latest reply on Mar 6, 2012 1:19 PM by zeeman

    partial-response xml  displayed in browser

    predrag

      Hi,

       

      I'm using JBoss 7.1, Seam 3.1, RichFaces 4.2 and PrimeFaces 3.1.1 in my project.

       

      I tried to handle ViewExpiredException in the exact way as described in http://weblogs.java.net/blog/edburns/archive/2009/09/03/dealing-gracefully-viewexpiredexception-jsf2

       

      I created the very same exception handler and viewExpired page as described in the article. And it works fair enough when view expires and user submits whole form, par example  by clicking on some h:commandButton.

       

      But when a ViewExpiredException occurs on partial (ajax) request, instead of getting redirected to the viewExpired page, i get partial-response xml displayed in a browser. The workflow is the following:

      1. user invokes ajax request (clicks on some a4j:commandButton)
      2. since session is no longer valid authorization exception occurs and user is redirected to the login page
      3. user signs in
      4. instead of getting redirected to viewExpired page user gets to the original page that request has been made from with all ajax request related parameters writen in the address bar as GET parameters (....?AJAX:EVENTS_COUNT=1&javax.faces.ViewState=-4145463206519941513:-5358807148169935734&javax.faces.partial.ajax=true&  ....)
      5. browser displays the following:

      <partial-response>

           <changes>

                <update id="studySearchForm:foundStudiesTable">

                     <![CDATA[...some response data...]]>

                </update>

                <update id="javax.faces.ViewState">

                     <![CDATA[ 7189954699325574858:-5545865599130186259 ]]>

                </update>

           </changes>

      </partial-response>

       

      Any idea how to solve this and redirect user to the desired page using view expired exception handler? (error-page will not do the trick for me since I need to add some business logic to be executed when this exception occurs)

       

      Thanks in advanced!

        • 1. Re: partial-response xml  displayed in browser
          lightguard

          Have you ruled out this being a Mojarra bug and it's actually a Seam, AS7, RichFaces, or PrimeFaces issue? That would be my first idea. Take things out and start adding them back in a little bit at a time and see where you see this break.

          • 2. Re: partial-response xml  displayed in browser
            zeeman

            I have heard horror stories about mixing JSF libs like RF and PF. I use seam catch and below works well for catching view expired exception.

             

            public void onExpiredView(@Handles final CaughtException<javax.faces.application.ViewExpiredException> event) {

                                event.unmute();

                                event.handled();

                                try {

                                          externalContext.redirect(HOME_PAGE);

                                } catch (final IOException e) {

                                          logger.error(e);

                                }

                      }

            • 3. Re: partial-response xml  displayed in browser
              predrag

              Thanks for your answers.

               

              I took Jason's advice and tried to determine where the problem is coming from. So I tested view expired exception handler on the project that does not use PrimeFaces, but it uses everything else (RichFaces 4.2, Seam 3.1 and it runs on JBoss AS 7.1). And there everything works just fine (even better than I was hoping for).

               

              So this actually seems to be a problem with PrimeFaces and redirecting after partial (ajax) request has been received. I will post a question on their forum and share the link here if anyone manages to solve this problem.

               

              Thanks again.

              • 4. Re: partial-response xml  displayed in browser
                zeeman

                I use Primefaces with code shown above without issues. Seems like you have some configuration issues.