10 Replies Latest reply on Apr 20, 2016 5:10 AM by michpetrov

    Ajax requests not invoked properly in RF 4.5.14 & 4.5.15 when context-param javax.faces.SEPARATOR_CHAR is set

    blebleskeble

      Hi all,

       

      after upgrade from RF 4.5.13 to higher version (.14 or .15) all ajax request suddenly stopped working. I have found out that it is caused by javax.faces.SEPARATOR_CHAR that i have set to _

      When setting for this param is removed, everything works as it should..

       

      my configuration is: Tomcat 7.0.68, MyFaces 2.2.9. I have created simple application where this fault can be reproduced (enclosed war). Is there any way to make it work/fix this?

       

      Thanks

        • 1. Re: Ajax requests not invoked properly in RF 4.5.14 & 4.5.15 when context-param javax.faces.SEPARATOR_CHAR is set
          blebleskeble

          Just have found out that this error ocures only if app is started from eclipse. Once WAR is copied into tomcat and run it again works as desired...

          • 2. Re: Ajax requests not invoked properly in RF 4.5.14 & 4.5.15 when context-param javax.faces.SEPARATOR_CHAR is set
            michpetrov

            That looks like a problem with eclipse then, can you try with a4j:log and see if there's any error? I don't see what in 4.5.14 would cause this.

            • 3. Re: Ajax requests not invoked properly in RF 4.5.14 & 4.5.15 when context-param javax.faces.SEPARATOR_CHAR is set
              blebleskeble

              a4j:log ocmponent is silent in this case...

              debug[13:47:09.876]: New request added to queue. Queue requestGroupingId changed to frm_btnSayHello

               

              debug[13:47:09.878]: Queue will wait 0ms before submit

              debug[13:47:09.879]: richfaces.queue: will submit request NOW

              info [13:47:09.884]: Received 'begin' event from <input id=frm_btnSayHello ...>

              info [13:47:11.851]: Received 'beforedomupdate' event from <input id=frm_btnSayHello ...>

              debug[13:47:11.853]: Server returned responseText: <?xml version="1.0" encoding="UTF-8"?><partial-response id="j_id__v_0"><changes><update id="j_id__v_0_javax.faces.ViewState_1"><![CDATA[5WJAT24gxrkzFlqI2JkEr2t7cq8ZuRbVGXgj1zvXzHG9AEPe]]></update></changes></partial-response>

              info [13:47:11.858]: Listing content of response changes element:
              Element update for id=j_id__v_0_javax.faces.ViewState_1
              <update id="j_id__v_0_javax.faces.ViewState_1"><![CDATA[5WJAT24gxrkzFlqI2JkEr2t7cq8ZuRbVGXgj1zvXzHG9AEPe]]></update>

              debug[13:47:11.861]: richfaces.queue: ajax submit successfull

              debug[13:47:11.862]: richfaces.queue: Nothing to submit

              info [13:47:11.864]: Received 'success' event from <input id=frm_btnSayHello ...>

              info [13:47:11.866]: Received 'complete' event from <input id=frm_btnSayHello ...>

               

               

               

              Here is request and response when ajax fails:

              Accept

              text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

              Accept-Encoding

              gzip, deflate

              Accept-Language

              cs,en-US;q=0.7,en;q=0.3

              Content-Length

              414

              Content-Type

              application/x-www-form-urlencoded; charset=utf-8

              Cookie

              JSESSIONID=0B4966DBBDFA942378BDF45747CFC4B4; oam.Flash.RENDERMAP.TOKEN=mvbgdfx06

              Faces-Request

              partial/ajax

              Host

              localhost:8080

              Referer

              http://localhost:8080/RFTest/faces/index.xhtml

              User-Agent

              Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0

               

              http://localhost:8080/RFTest/faces/index.xhtml
              AJAX:EVENTS_COUNT=1
              frm=frm
              frm_SUBMIT=1
              frm_btnSayHello=frm_btnSayHello
              frm_iName=name
              javax.faces.ViewState=eOAfBDV9zWo3MOJ8fAh081gNTdjebNcleKUc8qZLtTWNECjJ
              javax.faces.partial.ajax=true
              javax.faces.partial.event=click
              javax.faces.partial.execute=@component
              javax.faces.partial.render=@component
              javax.faces.source=frm_btnSayHello
              org.richfaces.ajax.component=frm_btnSayHello
              rfExt=null
              richfaces.log=debug
              

               

               

              Cache-Control

              no-cache

              Content-Type

              text/xml;charset=UTF-8

              Date

              Mon, 18 Apr 2016 11:47:11 GMT

              Expires

              -1

              Pragma

              no-cache

              Server

              Apache-Coyote/1.1

              Set-Cookie

              oam.Flash.RENDERMAP.TOKEN=mvbgdfx07; Path=/RFTest; HttpOnly

              Transfer-Encoding

              chunked

               

              <partial-response id="j_id__v_0">
              <changes>
              <update id="j_id__v_0_javax.faces.ViewState_1">eOAfBDV9zWo3MOJ8fAh081gNTdjebNcleKUc8qZLtTWNECjJ</update>
              </changes>
              </partial-response>
              

               

               

               

              And here when it is successful:

               

              Accept

              text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

              Accept-Encoding

              gzip, deflate

              Accept-Language

              cs,en-US;q=0.7,en;q=0.3

              Content-Length

              416

              Content-Type

              application/x-www-form-urlencoded; charset=utf-8

              Cookie

              JSESSIONID=C01FBB841503021AC1660C6C89EF1058; oam.Flash.RENDERMAP.TOKEN=-hpxzijbe8

              Faces-Request

              partial/ajax

              Host

              localhost:8080

              Referer

              http://localhost:8080/RFTest/faces/index.xhtml

              User-Agent

              Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0

               

              http://localhost:8080/RFTest/faces/index.xhtml
              AJAX:EVENTS_COUNT=1
              frm=frm
              frm_SUBMIT=1
              frm_btnSayHello=frm_btnSayHello
              frm_iName=name
              javax.faces.ViewState=CPwIJ6P2a9EU66YuE+MuwzMJq3244iWj5temyMcpOSAMlz6k
              javax.faces.partial.ajax=true
              javax.faces.partial.event=click
              javax.faces.partial.execute=@component
              javax.faces.partial.render=@component
              javax.faces.source=frm_btnSayHello
              org.richfaces.ajax.component=frm_btnSayHello
              rfExt=null
              richfaces.log=debug
              
              

               

               

              Cache-Control

              no-cache

              Content-Type

              text/xml;charset=UTF-8

              Date

              Mon, 18 Apr 2016 11:40:06 GMT

              Expires

              -1

              Pragma

              no-cache

              Server

              Apache-Coyote/1.1

              Set-Cookie

              oam.Flash.RENDERMAP.TOKEN=-hpxzijbe7; Path=/RFTest; HttpOnly

              Transfer-Encoding

              chunked

               

              <partial-response id="j_id__v_0">
              <changes>
              <update id="frm_greeting"><span id="frm_greeting">Hello name!</span></update>
              <update id="j_id__v_0_javax.faces.ViewState_1">CPwIJ6P2a9EU66YuE+MuwzMJq3244iWj5temyMcpOSAMlz6k</update>
              <extension id="org.richfaces.extension">
              <render>frm_greeting</render>
              </extension>
              </changes>
              </partial-response>
              
              
              • 4. Re: Ajax requests not invoked properly in RF 4.5.14 & 4.5.15 when context-param javax.faces.SEPARATOR_CHAR is set
                michpetrov

                IAs far as I can see underscore is not a good choice for the separator. In MyFaces a default ID may look like this: "j_id_v_2_1:j_id_v_2_2", so when you change the separator - "j_id_v_2_1_j_id_v_2_2" then the id can't be split into correct parts. However this will break in pretty much every version of RichFaces and if you avoid default ids it should work.

                • 5. Re: Ajax requests not invoked properly in RF 4.5.14 & 4.5.15 when context-param javax.faces.SEPARATOR_CHAR is set
                  blebleskeble

                  Hi,

                  I think that underscore is not to blame. Same problem can be reproduced with for example § or * or ; or Z

                  anything but default...

                  • 6. Re: Ajax requests not invoked properly in RF 4.5.14 & 4.5.15 when context-param javax.faces.SEPARATOR_CHAR is set
                    michpetrov

                    Yeah as I said if underscore was the issue it would've broken earlier, I'd still recommend not using it though (or any other character that might be part of a default id)

                     

                    We are obtaining the separator character from JSF so I still don't understand why it would be failing, can you check what's the value of org.richfaces.util.SeparatorChar.SEPARATOR_CHAR?

                    • 7. Re: Ajax requests not invoked properly in RF 4.5.14 & 4.5.15 when context-param javax.faces.SEPARATOR_CHAR is set
                      blebleskeble

                      org.richfaces.util.SeparatorChar.SEPARATOR_CHAR is : even if context param is set to _

                      • 8. Re: Ajax requests not invoked properly in RF 4.5.14 & 4.5.15 when context-param javax.faces.SEPARATOR_CHAR is set
                        michpetrov

                        This is our code:

                        public static final char SEPARATOR_CHAR = UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance());
                        

                         

                        This is MyFaces 2.2.9:

                        public static char getSeparatorChar(FacesContext context)
                        {
                            Map<Object, Object> attributes = context.getAttributes();
                            Character separatorChar = (Character) attributes.get(SEPARATOR_CHAR_PARAM_NAME);
                            if (separatorChar == null)
                            { // not cached yet for this request
                                ExternalContext eContext = context.getExternalContext();
                                    
                                // The implementation must determine if there is a <context-param> with the value given by the 
                                // value of the symbolic constant SEPARATOR_CHAR_PARAM_NAME
                                String param = eContext.getInitParameter(SEPARATOR_CHAR_PARAM_NAME);
                                if (param == null || param.length() == 0)
                                {
                                    // Otherwise, the value of the symbolic constant NamingContainer.SEPARATOR_CHAR must be returned.
                                    separatorChar = NamingContainer.SEPARATOR_CHAR;
                                }
                                else
                                {
                                    // If there is a value for this param, the first character of the value must be returned from 
                                    // this method
                                    separatorChar = param.charAt(0);
                                }
                                // Cache it under standard name
                                attributes.put(SEPARATOR_CHAR_PARAM_NAME, separatorChar);
                            }
                            return separatorChar.charValue();
                        }
                        

                         

                        So if it returned ":" it means that the context param was not found. That's not an issue with RichFaces, something is wrong with the deployment.

                        • 9. Re: Ajax requests not invoked properly in RF 4.5.14 & 4.5.15 when context-param javax.faces.SEPARATOR_CHAR is set
                          blebleskeble

                          This is strange, because

                          ((Character) FacesContext.getCurrentInstance().getAttributes().get("javax.faces.SEPARATOR_CHAR")).charValue()
                          

                          returned _

                           

                          while

                          org.richfaces.util.SeparatorChar.SEPARATOR_CHAR
                          

                          returned :

                          • 10. Re: Ajax requests not invoked properly in RF 4.5.14 & 4.5.15 when context-param javax.faces.SEPARATOR_CHAR is set
                            michpetrov

                            SeparatorChar is initialized during deploy, I can only assume the parameters are incomplete at that point. But I can't reproduce the issue, whether I deploy from eclipse or through the Tomcat console the separator is set correctly.