3 Replies Latest reply on May 10, 2011 5:04 PM by Ilya Shaikovsky

    <rich:tabPanel> tabs validation

    Vladimir Becarevic Newbie

      Hello everyone.

       

      I have some questions about rich:tabPanel component.

       

      My team is developing application using RichFaces 3.3.3 and came across some problem while working on gui.

       

      We created tabPanel with 3 tabs, each tab has few input fileds. On each tab, inputs have validation. Outside the tabPanel, we have one commandButton, which saves data from thoose inputs. When I click save button, inputs won't save, because I forgot to enter data on other tabs.

       

      Is there a way, when I click on save button, that validation notify me if I didn't enter data on inputs on other tabs, like opening the tab where validation didn't pass or coloring the tab?

       

      Thanks for your time and reply.

        • 1. <rich:tabPanel> tabs validation
          Ilya Shaikovsky Master

          seems tricky but possible actually. You just need to bind activeItem to some model property. Then in getter you could figure out if there are any messages in context and if so check inside which tab container the component which causes the messages lies. Then just change that current item name in model and  return it. And if there are no messages just return the current active Item as usually.

           

          In order to create something even more cool could try to find all the tabs with fallen validation and add header CSS class on backend to highlight tab in some way. But then on sucessfull validation need to remove it manually also.

           

          If will have much problems trying to implement this - please update the thread and I will try to assist you more.

          • 2. <rich:tabPanel> tabs validation
            Vladimir Becarevic Newbie

            Ilya, thanks for fast reply.

            Could you give me some guide or example, because I am relatively new to richFaces.

             

            Maybe we can solve problem with other approach. Let's say I have 5 tabs in tabPanel, and all tabs have inputs and each input has some validation.
            But only inputs on first tab are mandatory, so when I click on save button, I don't want to trigger validation on other tabs. I just want to trigger validation on current tab with mandatory inputs.

             

            Is that possible and how?

             

            Thanks again for your time and replies.

            • 3. <rich:tabPanel> tabs validation
              Ilya Shaikovsky Master

              you could limit processing by using execute="somecontainerid".. It could be panel inside the tab which holds inputs. But if the same button should update the model with the values from other tabs - it should not be used. As execute limits tree processing at all the processing phases (decode/validation/update model).

               

              But if you sure b.t.w. that all the inputs which has validations placed for example in the first tab - then the task getting pretty easier. Just use the same approach as I described above but in the activeItem getter return always first tab name in case facesContext contains messages.