4 Replies Latest reply on Jun 3, 2008 5:52 AM by YevgenK

    TabNavigator and Validator problem

    YevgenK
      Application sample http://www.floridawebdev.com/flex/test1.html
      Enter wrong hours or minutes and change focus.
      Message box will appear.
      But if you will click "tab 2" you will see new canvas and ONLY after it message box.
      I want to prevent it. I would like to stay at the tab with invalid field.
        • 1. Re: TabNavigator and Validator problem
          Doc816
          write this line in your validator function:

          tabnavigator.selectedindex = 0;

          that will bring the focus back to the first tab.
          • 2. Re: TabNavigator and Validator problem
            YevgenK Level 1
            quote:

            Originally posted by: Doc816
            write this line in your validator function:
            tabnavigator.selectedindex = 0;
            that will bring the focus back to the first tab.

            I can't do it because:
            1. timeselector is a component
            2. it can be used many times on a few tabs
            • 3. Re: TabNavigator and Validator problem
              John Hall Level 4
              But if it's always at the same level of a container inside a tab, could you refer to the parent and get the selectedIndex before you leave and reset it to that selectedIndex
              • 4. Re: TabNavigator and Validator problem
                YevgenK Level 1
                quote:

                Originally posted by: John Hall
                But if it's always at the same level of a container inside a tab, could you refer to the parent and get the selectedIndex before you leave and reset it to that selectedIndex

                Tab Navigator has a few events. For mentioned above you have to use 2 events:
                1. change - here you have to capture 2 values; oldIndex and id. you can't cancel action here because at this moment you don't know about validation error.
                2. updateComplete - here you are on new tab and don't have info about oldIndex. You have to use captured on first stage info. Now you knowabout validator status and can return back to oldIndex.

                There are a lot of additional variables and code involved into this process.
                It is really painful to track everything due to TabNavigator bug which should fire "Focus out" event for validated object and cancel moving to new tab if there was validation error.