1 Reply Latest reply on Feb 10, 2008 4:34 PM by Ratsnackbar

    Detect if tab is in focus or similar?

      Hi guys,

      My app is structured so that main.mxml has a tab navigator which uses moduleloader to load modules to the relevant canvas's.

      main.mxml preloads the modules using

      The user then selects module 1 tab, enters data into a dg and submits this data to a mysql server with a buttonclick.

      Module 2 on creationcomplete runs a function which gets the ID from the database that the user has just submitted in module1 and returns the related data.

      However when the user clicks module two the wrong data is selected. If I refresh the browser the correct data is displayed.

      I need something that detects that the module has gained focus and then runs the function.

      Any ideas?
        • 1. Re: Detect if tab is in focus or similar?
          Ratsnackbar Level 2
          Many ways to do this but I actually suggest a different path then trying to concern yourself with the FocusManager.

          You say it submits to a MySQL server. Are you using a Middleware server or submitting directly to a local server.

          If you are making webservice or remoteObject calls then you can send the ID back in the return and have that trigger another call to get the data and place it into your dataProvider. Or even better might just want to have it send that record back along with the id.

          If you are not using any type of Middleware I would suggest you do. Otherwise you may just want to write a stored procedure into the MySQL Database so that when the submission happens it inserts it and then automatically performs a select on that record and sends the query back.

          This way the same script that submits the form can be waiting for the returned data to inject into a dataProvider that your second Module is ready to use.

          The dataProvider could simply be a valueObject or you could use the command pattern to pass data back and fourth.