8 Replies Latest reply on Jan 12, 2010 9:45 AM by Ilya Shaikovsky

    richfaces tabs + form submit

    sv kap Newbie

      Hi all.

       

      I have a problem with submitting forms inside richfaces tab panel. When the form is outside the tab panel it works fine. When I add it to some tab #{testeBean.testForm} is not executed. However it makes a new request and the tab panel switches to the first tab.

       

          <rich:tabPanel id="pnlTestTbSet" switchType="server"
                      selectedTab="#{testBean.selectedTab}"
                      valueChangeListener="#{testBean.tabPanelSwitched}">               

                      <rich:tab id="testtab1id" rendered="true" label="test 1"
                          title="test 1">       
                      <h:form id="someOtherForm">   
                          <h:outputText value="test 1" />                   
                      </h:form>
                      </rich:tab>

                      <rich:tab rendered="#{testBean.renderEditProfile}"
                          id="test2TabId" label="test 2" title="test 2">

                          <f:view>
                              <h:form id="testForm">
                                  <h:panelGrid columns="3"
                                      columnClasses="pnlGrdClass, pnlGrdClass, pnlGrdClassLong">

                                      <h:outputLabel for="TxtTest" value="Test:"
                                          style="line-height:200%" />
                                      <h:inputText id="TxtTest" size="30" maxlength="30"
                                          value="#{testBean.name}" required="true">
                                          <f:validateLength minimum="3" maximum="40" />
                                          <rich:ajaxValidator event="onblur" />
                                      </h:inputText>
                                      <rich:message id="testMsg" for="TxtTest"
                                          errorClass="errorMessage" />
                                 
                                  </h:panelGrid>

                                  <h:commandButton id="btnTestSubmit"
                                      image="/img/button-submit.gif"
                                      action="#{testeBean.testForm}"
                                      style="float: right; border: 0;" />
                              </h:form>
                          </f:view>

                      </rich:tab>

                      <rich:tab id="calendarTabId"
                          rendered="#{testBean.renderEditProfile}" label="tab3"
                          title="tab3" name="tab3">
                         
                          <h:outputText value="tab3" />
                      </rich:tab>

          </rich:tabPanel>

       

      Have anyone had similar problems?

        • 1. Re: richfaces tabs + form submit
          Ilya Shaikovsky Master

          1) testBean scope?

          2) do you removing external form while defining the form inside the tab?

          • 2. Re: richfaces tabs + form submit
            sv kap Newbie

            1) testBean is with Request scope.

            2) There is no external form. The tab panel and forms are defined just like they are shown. Tab panel is not in a from. However there are separate forms on some tabs (tab 1 and tab 2). When I try this form outside of tab panel I just copy

             

            <f:view>
                <h:form id="testForm">

            ........

            ........

                 </h:form>
            </f:view>

             

            and paste it on the same page right after the tab panel (it works fine that way).

            • 3. Re: richfaces tabs + form submit
              Ilya Shaikovsky Master

              B.t.w. action="#{testeBean.testForm}" seems need to be corrected to be testBean

              • 4. Re: richfaces tabs + form submit
                sv kap Newbie
                Yes . However this is not the problem. I have renamed the original Bean name and it seems that I have missed to delete the "e" there...
                • 5. Re: richfaces tabs + form submit
                  Ilya Shaikovsky Master
                       <rich:tabPanel switchType="server">
                            <rich:tab label="First">
                                 Here is tab #1
                                 <h:inputText value="#{userBean.name}" />
                            </rich:tab>
                            <rich:tab label="Second">
                       <h:form>
                                 Here is tab #2
                                 <h:inputText value="#{userBean.job}" />
                       <h:commandButton  value="click " action="#{userBean.action}"/>
                       </h:form>
                            </rich:tab>
                       </rich:tabPanel>
                  works for me.
                  could be caused by the fact that you storing "rendered" and "currently selected" properties in request scoped bean. try to use session.
                  • 6. Re: richfaces tabs + form submit
                    sv kap Newbie
                    I tried using session scope, as well as not using "rendered" and "currently selected" properties. The result is the same... The problem must be elsewhere but unfortunately I cannot see it ... By the way I have used component showcase application as an example to implement restful tabs and that is why I am using this property. Do you have other ideas?
                    • 7. Re: richfaces tabs + form submit
                      sv kap Newbie

                      Hi.

                       

                      Actually the problem was in selectedTab and valueChangeListener methods of the tabPanel and the request scope of the bean. I fixed that but unfortunatelly I do not need session scope for that bean so I decided to go to jsf 2.0 and view scope. However I have some difficulties migrating to RF 3.3.3 BETA and jsf 2.0 but I will start a new thread for that. Thank you.

                      • 8. Re: richfaces tabs + form submit
                        Ilya Shaikovsky Master
                        keepAlive could be also used in 3.3.3 and JSF 1.2 to achieve the same results as will be with Seam conversation or JSF 2 viewScope.