7 Replies Latest reply on Jun 10, 2009 7:15 AM by Ilya Shaikovsky

    <a4j:support> and Internet Explorer

    Sharif Aboulnaga Newbie

      Does anyone know if there has been a solution to the issue of a4j:support and Internet Explorer?

      Mozilla works fine when it comes to using it, but IE doesn't respond to a4j requests.

      Any information about how to fix this would be helpful. Also, if you have any information about all the things that won't work with IE, that would be helpful too.

        • 1. Re: <a4j:support> and Internet Explorer
          Nick Belaevski Master

          Hello,

          What issue is this post about? Internet Explorer is fully supported and a4j:support works perfectly on livedemo in IE.

          • 2. Re: <a4j:support> and Internet Explorer
            José Ventura Newbie

            Hello,

            I'm not sure this is the same issue as the OP had in mind, but I also have a problem with Internet Explorer and some Ajax functionality. I will describe the problem below, but it is such a simple problem that I'm sure it has something to do with my configuration.

            I have made a very simple test page. I'm using richfaces-ui-3.3.0.GA and facelets-1.1.14, on Tomcat 5.5.26.

            I have the following test.xhtml:

            <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:sense="http://www.sensedia.com/facelets"
            xmlns:c="http://java.sun.com/jstl/core"
            xmlns:a4j="http://richfaces.org/a4j"
            xmlns:rich="http://richfaces.org/rich"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core">
            
            <head>
             <link rel="stylesheet" type="text/css" href="repository-styles.css" />
            </head>
            
            <body>
             <h:form>
             <a4j:commandLink action="#{TestBean.myMethod}" value="Go" />
             </h:form>
            </body>
            
            </html>
            


            TestBean.java has a simple method:

            public String myMethod() {
             System.out.println( "returning to home" );
             return "home";
            }
            


            which is a navigation case defined in my faces-config.xml :

             <navigation-rule>
             <navigation-case>
             <from-outcome>home</from-outcome>
             <to-view-id>/main/home.jsf</to-view-id>
             </navigation-case>
             </navigation-rule>
            


            Currently, the behavior is as follows:

            Firefox 3.0.7 (Ubuntu): When I access test.jsf, the page is rendered. When I click the button, I see the output of the System.out statement in the console. Firefox then gets correctly redirected to my application's start page.

            Internet Explorer 7 (WinXP): Same as above, I can also see the System.out output, but IE doesn't return to the start page.

            I'm going to test other versions of IE soon, perhaps debugging the javascript, althought it's harder for me to do it on IE. I have also read that adding a special HTTP header may help:

            (from https://jira.jboss.org/jira/browse/RF-4113):

            response.setHeader("Location", "login.jsp");
            response.setHeader("Ajax-Response", "redirect");


            I will try this too. Has anybody else experienced similar errors? Seems that when the AJAX response includes a redirect status (302) Firefox -- or A4J, I'm not sure -- understands that it should follow the redirect, while IE7 doesn't.

            I have used a4j:commandLink in other situations, in pages where the link does not cause a redirect (only rerenders a few components on the page). This works fine. But when I have to go to a different navigation case, the same error happens.

            Thanks in advance!

            • 3. Re: <a4j:support> and Internet Explorer
              Sharif Aboulnaga Newbie

              Jose,

              I'm not sure how to fix this issue, but based on your code, this is what I think you should do.

              <head>
               <link rel="stylesheet" type="text/css" href="repository-styles.css" />
              </head>
              
              <body>
               <h:form>
               <a4j:commandLink actionListener="#{TestBean.myMethod}" action="home" value="Go" />
               </h:form>
              </body>
              
              </html>


              Update your bean to remove the return type:
              public void myMethod() {
               System.out.println( "returning to home" );
              }
              


              Everything else can remain the same. This might be the issue.





              "jose.ventura" wrote:
              Hello,

              I'm not sure this is the same issue as the OP had in mind, but I also have a problem with Internet Explorer and some Ajax functionality. I will describe the problem below, but it is such a simple problem that I'm sure it has something to do with my configuration.

              I have made a very simple test page. I'm using richfaces-ui-3.3.0.GA and facelets-1.1.14, on Tomcat 5.5.26.

              I have the following test.xhtml:

              
              <html xmlns="http://www.w3.org/1999/xhtml"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:sense="http://www.sensedia.com/facelets"
              xmlns:c="http://java.sun.com/jstl/core"
              xmlns:a4j="http://richfaces.org/a4j"
              xmlns:rich="http://richfaces.org/rich"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core">
              
              <head>
               <link rel="stylesheet" type="text/css" href="repository-styles.css" />
              </head>
              
              <body>
               <h:form>
               <a4j:commandLink action="#{TestBean.myMethod}" value="Go" />
               </h:form>
              </body>
              
              </html>
              


              TestBean.java has a simple method:

              public String myMethod() {
               System.out.println( "returning to home" );
               return "home";
              }
              


              which is a navigation case defined in my faces-config.xml :

               <navigation-rule>
               <navigation-case>
               <from-outcome>home</from-outcome>
               <to-view-id>/main/home.jsf</to-view-id>
               </navigation-case>
               </navigation-rule>
              


              Currently, the behavior is as follows:

              Firefox 3.0.7 (Ubuntu): When I access test.jsf, the page is rendered. When I click the button, I see the output of the System.out statement in the console. Firefox then gets correctly redirected to my application's start page.

              Internet Explorer 7 (WinXP): Same as above, I can also see the System.out output, but IE doesn't return to the start page.

              I'm going to test other versions of IE soon, perhaps debugging the javascript, althought it's harder for me to do it on IE. I have also read that adding a special HTTP header may help:

              (from https://jira.jboss.org/jira/browse/RF-4113):

              response.setHeader("Location", "login.jsp");
              response.setHeader("Ajax-Response", "redirect");


              I will try this too. Has anybody else experienced similar errors? Seems that when the AJAX response includes a redirect status (302) Firefox -- or A4J, I'm not sure -- understands that it should follow the redirect, while IE7 doesn't.

              I have used a4j:commandLink in other situations, in pages where the link does not cause a redirect (only rerenders a few components on the page). This works fine. But when I have to go to a different navigation case, the same error happens.

              Thanks in advance!


              • 4. Re: <a4j:support> and Internet Explorer
                Nick Belaevski Master

                Hi Jose,

                Use redirect for AJAX navigation as recommended in documentation.

                • 5. Re: <a4j:support> and Internet Explorer
                  Nick Belaevski Master

                  Sharif,

                  Can you please clarify: is the question about AJAX navigation?

                  • 6. Re: <a4j:support> and Internet Explorer
                    José Ventura Newbie

                    Thanks a lot for your responses, nbelaevski and Sharif. Looks like I missed that section of the documentation, I will read more about it now.

                    I modified my navigation case to always be a redirect (I followed nbelaevski directions first; I will try your suggestion soon, Sharif):

                     <navigation-case>
                     <from-outcome>home</from-outcome>
                     <to-view-id>/main/home.jsf</to-view-id>
                     <redirect/>
                     </navigation-case>
                    


                    Now, both IE and Firefox have the same behaviour. However, this causes another problem: FacesMessages placed into FacesContext are lost. I suppose this happens because they are tied with the request scope.

                    I modified my bean to look like this:

                    public String myMethod() {
                     FacesContext.getCurrentInstance().addMessage( null,
                     new FacesMessage( "Success Message" ) );
                     System.out.println( "returning to home" );
                     return "home";
                    }
                    


                    and placed the following in the second page (it's basically empty save for this):

                    <f:view>
                     <h:messages/>
                    </f:view>
                    


                    Without the < redirect /> tag (i.e. in my previous case), when I use Firefox to click on the link, I see the System.out output, and the resulting page displays the "Success Message". IE stays on the same page, obviously.

                    With the < redirect /> tag, both browsers go to the resulting page, but neither of them displays the success message. Is there anything else that I should do to make the messages persist after a redirect? Some kind of a4j:keepAlive for the messages?

                    Reading the docs, section 5.4 reccomends "to place messages in the 'AjaxOutput' component", but I found no such component in the reference... is it referring to an a4j:outputPanel with ajaxRendered="true"?

                    For validation and error messages, I understand the action method should return null and reRender a panel that contains messages. I'm doing this and it works fine in both browsers. In the problem scenario, however, it is a success message that I want to display...

                    Perhaps I need to use a session-scoped managed bean to retrieve the messages, and delete them once they are "consumed"?

                    Thanks in advance again!

                    • 7. Re: <a4j:support> and Internet Explorer
                      Ilya Shaikovsky Master

                      yes.. in case when you doing redirect you have to store messages on your own because it's request scoped.