5 Replies Latest reply on Mar 9, 2011 7:37 AM by geschtli

    Second click problem resolved

    geschtli Newbie

      Ilya are right. There is no intervention required.


      Two different ajax views should be handled in ONE form, and

      not in two separate.


      A simple example shows it:



      <ui:define name="top">


                   <h:panelGrid id="panel" columns="5">


                     <h:panelGroup rendered="#{!loginBean.loggedIn}">


                     <!--  <ui:include src="/sections/header/loginHeader.xhtml"/> -->

                     <div style="width:60%;font-size:14px;line-height:42px;background-color:white;color:black">



                         <h:outputText value="#{msg.name}" />

                         <h:inputText value="#{loginBean.alias}" required="true" />

                         <h:outputText value="#{msg.pwd}" />

                         <h:inputSecret  value="#{loginBean.password}"  required="true" />

                         <h:commandButton value="Login" action="#{loginBean.checkLogin}" >

                            <a4j:ajax execute="@form" render=":refl" />






                     <h:panelGroup rendered="#{loginBean.loggedIn}">

                        <!-- <ui:include src="/sections/header/logoutHeader.xhtml"/> -->


                         <h:commandButton value="Logout" action="#{loginBean.logout}" >

                            <a4j:ajax execute="@form" render=":refl" />











      The two commandButton tags should not be respectivaly suround with (<form></form>) tags.

        • 1. Second click problem resolved
          Rocky S Master

          good to know. You resolved your issue.

          • 2. Re: Second click problem resolved
            nimo stephan Master

            Why is that so?


            Why do I have to put two different ajax calls of a page within the SAME form ?



            I have had the same problem. When using two different forms and submitting a selectOneMenu of the second form via ajax by selecting an item nothing happens. When selecting again, the item is being selected successfully. So I have to select twice because the first select is ignored. Why is that so?


            When putting the selectOneMenu of the second form into the first form and do the ajax-select, then it works

            • 3. Second click problem resolved
              geschtli Newbie

              Good joke:-)

              But i thing, other developer have also that nasty handling

              with that.

              • 4. Re: Second click problem resolved
                nimo stephan Master

                It should be best practice to minimize the content within a form - why I am forced to wrap ALL my input-fields and the like within ONE form only to make ajax-calls? Of course, I can minimze the execute-tags but normally I want to logically group views into different forms and not into one whole form.

                • 5. Re: Second click problem resolved
                  geschtli Newbie

                  It's logically not always a good solution.


                  If you have all in separate files, think about this.


                  If you have a conditionally rendering, so that only

                  one component is rendered, the you can have to much

                  tags in your end script.


                  Suddenly in your client html script,

                  you can have such :



                  --- the rendered part ---



                  --- the not rendered part ---



                  But we need is only such:



                  --- the rendered part ---