4 Replies Latest reply on Nov 27, 2014 10:34 AM by martam

    How to prevent rich:tabPanel submitting whole form when switching tabs

    Jason Yang Newbie

      Hi,

       

      I found that each time switching tabs of tabPanel would make the whole surrounding form submitted with switchType set to 'ajax'.

       

      I'm using tabPanel in my app like following:

       

      <h:form>

           <rich:tabPanel switchType="ajax" activeItem="tab1">

                <rich:tab name="tab1">

                     <!-- some inputTexts here, i just omit something like labels, messages...-->

                     <h:inputText value="#{user.name}" />

                     <h:inputText value="#{user.sn}"  />

                     <h:commandButton action="#{user.modify}" value="modify">

                            <f:ajax ... />

                     </h:commandButton>

                </rich:tab>

                   

                <rich:tab name="tab2">

                     <!-- other inputTexts -->

                     <h:inputText value="#{ruleBean.type}" />

                       <h:commandButton action="#{ruleBean.add}" value="add">

                            <f:ajax ... />

                     </h:commandButton>

                </rich:tab>    

           </rich:tabPanel>

      </h:form>

       

      when i switch from tab1 to tab2, all the inputTexts (both within tab1 & tab2) values are posted, and thus update the back beans. However, it's not expected since there're already commandButtons to submit those inputTexts,  and users may change their info without awareness.

       

      Another problem is if there's a converter for ruleBean.type, and user may find himself unable to switch from tab2 to tab1 if an convertion exception thrown (maybe just leave the inputText empty).

       

      I know setting switchType to 'client' can settle these issues, but it will download all the tabs at once, and the data may be very large.

       

      Is there any other workaround for this question?