11 Replies Latest reply on Nov 14, 2007 10:53 AM by lmk

    [a4j support]  event on button ENTER

    lmk

      Hii..

      Id like to send ajax request by pressing the button ENTER, I have only an input text...

        • 1. Re: [a4j support]  event on button ENTER

          IE and FF react different ways on pressing ENTER. What browser you have to support?

          • 2. Re: [a4j support]  event on button ENTER
            lmk

             

            "SergeySmirnov" wrote:
            IE and FF react different ways on pressing ENTER. What browser you have to support?


            by priority..IE , FF


            • 3. Re: [a4j support]  event on button ENTER
              lmk

               

              
              <a4j:support event="onkeyup" onsubmit="if (event.keyCode != 13) { return false}" />
              



              it works on IE and FF ..

              best regards!

              • 4. Re: [a4j support]  event on button ENTER
                lmk

                sorryy ..

                the a4j:support do not reRender other component..:(



                • 5. Re: [a4j support]  event on button ENTER
                  dmitry.demyankov

                   

                  "lmk" wrote:
                  the a4j:support do not reRender other component..:(


                  You mean reRender attribute for the a4j:support in your case doesn't work? In my case it always reRendered specified components..

                  • 6. Re: [a4j support]  event on button ENTER
                    lmk

                     

                    "dmitry.demyankov" wrote:
                    "lmk" wrote:
                    the a4j:support do not reRender other component..:(


                    You mean reRender attribute for the a4j:support in your case doesn't work? In my case it always reRendered specified components..


                    yes it's what I mean to say...the components which id(s are specified on the reREndered attribute still not change..

                    when µI test with the onblur event, without the javascript test on a keyUp it work's fine..



                    • 7. Re: [a4j support]  event on button ENTER

                      Could you post the whole code snippet of this form.

                      • 8. Re: [a4j support]  event on button ENTER
                        lmk

                         

                        "SergeySmirnov" wrote:
                        Could you post the whole code snippet of this form.


                        <h:panelGrid columns="1">
                        <h:panelGroup>
                        <h:inputText value="#{queryManager.search}" id="text">
                        <a4j:support event="onkeyup"onsubmit="if (event.keyCode != 13) { return false}" reRender="table" action="#{queryManager.onSearch}" />
                        </h:inputText>
                        </h:panelGroup>
                        </h:panelGrid>
                        <rich:dataTable onRowMouseOver="this.style.backgroundColor='#F1F1F1'" onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                         cellspacing="0" width="850" border="0" var="list"
                        value="#{queryManager.results}" id="table" rows="50">
                        
                        .. ..
                        . ..
                        </..>
                        


                        the problem occurs on IE 7 only..I tried on FF and it works !!


                        • 9. Re: [a4j support]  event on button ENTER
                          dmitry.demyankov

                          I tried to make it work with the following code, but the result is pretty strange.. the "input_result" panel reRenders and outputText always shows the correct value. But rich:dataTable reRendering is very strange - the last element in the list it shows is the previous element entered in h:inputText. So when you press enter first time inputText value is added to the strList (TestMeth is called) but this value is rendered and shown in rich:dataTable only if you sumbit one more value.. Same happens both in IE 6 and FF 2.0.0.6..

                          Is there something wrong I'm doing here?

                          JSP:

                          <h:form>
                          <h:inputText value="#{testBean.testStr}" id="text">
                           <a4j:support event="onkeyup" onsubmit="if (event.keyCode != 13) { return false}" reRender="input_result, input_table" action="#{testBean.TestMeth}"/>
                          </h:inputText>
                          </h:form>
                          
                          <h:panelGrid id="input_result">
                          <h:outputText value="input result - #{testBean.testStr}"/>
                          </h:panelGrid>
                          
                          <rich:dataTable id="input_table" value="#{testBean.strList}" var="list">
                           <rich:column>
                           <h:outputText value="#{list.str}"/>
                           </rich:column>
                          </rich:dataTable>


                          TestBean is in session scope, code fragments:
                          private List<SampleClass> strList = new ArrayList<SampleClass>();
                          
                          public String TestMeth() {
                           System.err.println("TEST METH CALLED" + getTestStr());
                           strList.add(new SampleClass(getTestStr()));
                          
                           return null;
                          }


                          SampleClass is not a managed bean, it has only one field of type String.

                          • 10. Re: [a4j support]  event on button ENTER
                            dkane

                            I need the same functionality .
                            Tried the suggested code :

                            <h:inputText id="searchString" value="#{search.searchString}" style="width:165px;">
                             <a:support
                             event="onkeyup"
                             onsubmit="if (event.keyCode != 13) return false;"
                             actionListener="#{search.find}"/>
                            </h:inputText>


                            The result :
                            Firebug shows me the following error in console (only when Enter is pressed):

                            LOG is not defined
                            http://localhost:8080/avh/a4j_3_1_1-SNAPSHOTorg.ajax4jsf.javascript.AjaxScript
                            Line 18


                            The same action #{search.find} works fine from separate a:commandButton .

                            Any ideas ?

                            • 11. Re: [a4j support]  event on button ENTER
                              lmk

                              finnaly Im dont use the ENTER key..I struggled a bit with IE7 without success.
                              so, I use the event on blur, and the TAB key..

                              regardsl