Best practice for lazy-loading collection once but making sure it's there?

I'm confused on the best practice to handle the 'setup' of a form, where I need a remote call to take place just once for the form, but I also need to make use of this collection for a combobox that will change when different rows in the datagrid or clicked. Easier if I just explain...
You click on a row in a datagrid to edit an object (for this example let's say it's an "Employee")
The form you go to needs to have a collection of "Department" objects loaded by a remote call. This collection of departments only should happen once, since it's not common for them to change. The collection of departments is used to populate a form combobox.
You need to figure out which department of the comboBox is the selectedIndex by iterating over the departments and finding the one that matches the employee.department.id
Individually, I know how I can do each of the above, but due to the asynch nature of Flex, I'm having trouble setting up things. Here are some issues...
My initial thought was just put the loading of the departments in an init() method on the employeeForm which would load as creationComplete() event on the form. Then, on the grid component page when the event handler for clicking on a row was fired, I call a setup() method on my employeeForm which will figure out which selectedIndex to set on the combobox by looking at the departments.
The problem is the resultHandler for the departments load might not have returned (so the departments might not be there when 'setUp' is called), yet I can't put my business logic to determine the correct combobox in the departmentResultHandler since that would mean I'd always have to fire the call to the remote server object every time which I don't want.
I have to be missing a simple best practice? Suggestions welcome.

Hi there rickcr
This is pretty rough and you'll need to do some tidying up but have a look below.
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.collections.ArrayCollection;
            private var comboData:ArrayCollection;
            private function setUp():void {
                if (comboData) {
                    Alert.show('Data Is Present')
                    populateForm()
                } else {
                    Alert.show('Data Not')
                    getData();
            private function getData():void {
                comboData = new ArrayCollection();
                // On the result of this call the setUp again
            private function populateForm():void {
                // populate your form
        ]]>
    </mx:Script>
    <mx:TabNavigator left="50" right="638" top="50" bottom="413" minWidth="500" minHeight="500">
        <mx:Canvas label="Tab 1" width="100%" height="100%">
        </mx:Canvas>
        <mx:Canvas label="Tab 2" width="100%" height="100%" show="setUp()">
        </mx:Canvas>
    </mx:TabNavigator>
</mx:Application>
I think this example is kind of showing what you want.  When you first click tab 2 there is no data.  When you click tab 2 again there is. The data for your combo is going to be stored in comboData.  When the component first gets created the comboData is not instansiated, just decalred.  This allows you to say
if (comboData)
This means if the variable has your data in it you can populate the form.  At first it doesn't so on the else condition you can call your data, and then on the result of your data coming back you can say
comboData = new ArrayCollection(), put the data in it and recall the setUp procedure again.  This time comboData is populayed and exists so it will run the populate form method and you can decide which selected Item to set.
If this is on a bigger scale you'll want to look into creating a proper manager class to handle this, but this demo simple shows you can test to see if the data is tthere.
Hope it helps and gives you some ideas.
Andrew

Similar Messages

  • Best Practice for Initial Load Data

    Dear Experts,
        I would like to know the best practices or factors to be concerned when performing initial load
    For example,
    1) requirement from business stakeholders for data analysis
    2) age of data to meet tactical reproting
    3) data dependency crossing sap  modules
    4) Is there any best practice for loading master data?

    HI ,
    check this links
    Master Data loading
    http://searchsap.techtarget.com/guide/allInOne/category/0,296296,sid21_tax305408,00.html
    http://datasolutions.searchdatamanagement.com/document;102048/datamgmt-abstract.htm
    Regards,
    Shikha

  • Best practices for using .load() and .unload() in regards to memory usage...

    Hi,
    I'm struggling to understand this, so I'm hoping someone can explain how to further enhance the functionality of my simple unload function, or maybe just point out some best practices in unloading external content.
    The scenario is that I'm loading and unloading external swfs into my movie(many, many times over) In order to load my external content, I am doing the following:
    Declare global loader:
    var assetLdr:Loader = new Loader();
    Load the content using this function:
    function loadAsset(evt:String):void{
    var assetName:String = evt;
    if (assetName != null){
      assetLdr = new Loader();
      var assetURL:String = assetName;
      var assetURLReq:URLRequest = new URLRequest(assetURL);
      assetLdr.load(assetURLReq);
      assetLdr.contentLoaderInfo.addEventListener( Event.INIT , loaded)
      assetLdr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, displayAssetLoaderProgress);
      function loaded(event:Event):void {
       var targetLoader:Loader = Loader(event.target.loader);
       assetWindow.addChild(targetLoader);
    Unload the content using this function:
    function unloadAsset(evt:Loader) {
    trace("UNLOADED!");
    evt.unload();
    Do the unload by calling the function via:
    unloadAsset(assetLdr)
    This all seems to work pretty well, but at the same time I am suspicious that the content is not truly unloaded, and some reminents of my previously loaded content is still consuming memory. Per my load and unload function, can anyone suggest any tips, tricks or pointers on what to add to my unload function to reallocate the consumed memory better than how I'm doing it right now, or how to make this function more efficient at clearing the memory?
    Thanks,
    ~Chipleh

    Since you use a single variable for loader, from GC standpoint the only thing you can add is unloadAndStop().
    Besides that, your code has several inefficiencies.
    First, you add listeners AFTER you call load() method. Given asynchronous character of loading process, especially on the web, you should always call load() AFTER all the listeners are added, otherwise you subject yourself to unpredictable results and bud that are difficult to find.
    Second, nested function are evil. Try to NEVER use nested functions. Nested functions may be easily the cause for memory management problems.
    Third, your should strive to name variables in a manner that your code is readable. For whatever reason you name functions parameters evt although a better way to would be to name them to have something that is  descriptive of a parameter.
    And, please, when you post the code, indent it so that other people have easier time to go through it.
    With that said, your code should look something like that:
    function loadAsset(assetName:String):void{
         if (assetName) {
              assetLdr = new Loader();
              assetLdr.contentLoaderInfo.addEventListener(Event.INIT , loaded);
              assetLdr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, displayAssetLoaderProgress);
              // load() method MUST BE CALLED AFTER listeners are added
              assetLdr.load(new URLRequest(assetURL));
    // function should be outside of other function.
    function loaded(e:Event):void {
         var targetLoader:Loader = Loader(event.target.loader);
         assetWindow.addChild(targetLoader);
    function unloadAsset(loader:Loader) {
         trace("UNLOADED!");
         loader.unload();
         loader.unloadAndStop();

  • Best Practice for Initial Load

    Hello,
    what is the best way of doing the initial load? is there a best practice somwhere that tells you what should be imported first?
    I want to understand the order ex,
    1. load Lookups,
    2. Hierarchies,
    3. taxonomy and attributes
    last the main table
    etc...
    I dont understand the logic.
    Thanks in advance

    Hi Ario,
    If you follow any SAP Standard business content for MDM Repositories like e.g. Material.
    https://websmp130.sap-ag.de/sap/support/notes/1355137
    In the SAP Note attachments, you will get MDM71_Material_Content.pdf
    You will see Import of reference Data(look up table's data) 1st(step6) before import of Master data(step7).
    During Import of Reference Data(look up data), Please follow the Import Sequence by using Processing level 0,1,2 etc.
    Which take care of filling look up flat tables first then filling Hierarchies tables etc.
    After that if you are maintaining Taxonomy, You need to fill taxonomy table in Taxonomy mode of Data Manager, in the sequence (Categories, Attributes, Linkage between Attributes and Categories and lastly Attribute Values)
    After this I mean populating Reference data you need to populate Main table records along with tuples table data since now in MDM 7.1 Tuple has been replaced by Qualified table for most of the Master's but if you are still maintaining Qualified table you can import Mani table data along with Qualified table in a single step. Otherwise for Qualified table you can alos use this approach of populating Non-qualifeirs to Qualified table first before importing main table and then importing Main table data along with Qualifier's field of Qualified table.
    This above entire process for exporting data from SAP R/3 system to MDM. If you are importing data into MDM from legacy system (Non-Sap systems too), Approach should be remain same Populating Lookup tables data and lastly main table data.
    I dont understand the logic.
    The logic is simple in your main table you have fields which are look up to Reference tables( e.g. field in main table which are look up to Lookup flat tables like Countries, Currencies etc, field in main table which is lookup to Hierarchy/Taxonomy table etc). So, if these values are not populated firstly, so during your Main table import you will have incomplete data for all of these fields from main table which are look up to some other tables as values in your lookup table you haven't populated before Main table import.
    Kindly revert if you still have any doubts.
    Regards,
    Mandeep Saini

  • Best practice for storing/loading medium to large amounts of data

    I just have a quick question regarding the best medium to store a certain amount of data. Currently in my application I have a Dictionary<char,int> that I've created, that I subsequently populate with hard-coded static values.
    There are about 30 items in this Dictionary, so this isn't presented as much of a problem, even though it does make the code slightly more difficult to read, although I will be adding more data structures in the future with a similar number of items.
    I'm not sure whether it's best practice to hard-code these values in, so my question is, is there a better way to store this information, retrieve and load it at run-time?

    You could use one of the following methods:
    Use the application.config file. Upside is that it is easy to maintain. Downside is a user could edit it manually as its just an xml file.
    You could use a settings file. You can specify where the setting file is persisted including under the user's profile or the application. You could serialize/deserialize your settings to a section in the settings. See
    this MSDN help section
    on details abut the settings.
    Create a .txt, .json, or .xml file (depending on the format you will be deserializing your data) in your project and have it be copied to the output path with each build. The upside is that you could push out new versions in the future of the file without
    having to re-compile your application. Downside is that it could be altered if the user has O/S permissions to that directory.
    If you really do not want anyone to access it and are thinking of pushing out a new application version every time something changes you could create a .txt, .json, .xml file (depending on the format you will be deserializing your data) just like the previous
    step but this time mark it as an embedded resource in your project (you can do this in the properties of the  file in visual studio). It will essentially get compiled in your application. Content retrieval is outlined in
    this how to from Microsoft and then you just deserialize the retrieved content the same as the previous step.
    As far as formats of your data. I recommend you use either XML or JSON or a text file if its just a flat list of items (ie. list of strings). Personally I find JSON much easier to read compared to XML and change and there are plenty of supported serializers
    out there. XML is great too if you need to be strict as to what the schema is.
    Mark as answer or vote as helpful if you find it useful | Igor

  • Best practices for disabling an employees account, but leaving mailbox available for others while not accepting messages

    I'm sure that other organizations have some policy for this. In our case, we want to keep the mailbox available for others to still access, but disable the user account and remove it from OWA.
    In this case, I've disabled the AD object, disabled OWA from the features, and set the mailbox to only receive emails from a dummy mailbox (so that no new emails are accepted).
    This all works fine and senders receive a NDR that their mail was rejected, however I'd also like to set a friendlier custom NDR to call the office instead when any sender attempts to send email to that recipient.
    What would best practices, suggestions be for this behavior?

    Hi,
    According to your description, the user object in AD has been disabled.
    In this case, the mailbox cannot mostly likely be accessed. Thus, maybe OOF couldn’t help you.
    If I misunderstand your meaning, please feel free to let me know.
    And we can depend on transport rule:
    The recipient is
    send rejection message to sender with enhanced status code:
    http://technet.microsoft.com/en-us/library/bb123506(v=exchg.141).aspx
    Thanks,
    Angela Shi
    TechNet Community Support

  • Best practice for taking Site collection Backup with more than 100GB

    Hi,
    I have site collection data is more than 100 GB. Can anyone please suggest me the best practice to take backup?
    Thanks in advance....
    Regards,
    Saya

    Hi
    i think Using powershell script we can do..
    Add this command in powershell
    Add-PSSnapin Microsoft.SharePoint.PowerShell
    Web application backup & restore
    Backup-SPFarm -Directory \\WebAppBackup\Development  -BackupMethod Full -Item "Web application name"
    Site Collection backup & restore
    Backup-SPSite http://1632/sites/TestSite  -Path C:\Backup\TestSite1.bak
    Restore-SPSite http://1632/sites/TestSite2  -Path C:\Backup\TestSite1.bak -Force
    Regards
    manikandan

  • Best practice for handling original files once movie is complete?

    So I'm taking movies from my Canon S5IS (and other cameras in the past) and making projects in iMovie, sharing in the Media Browser, importing into iDVD, and burning to DVD.
    I can't help but wonder if I might need the original footage one day. Do most people keep their original files for future media (replacement for DVD) which I realize would require recreation of the movies that were created in 2008 with iMovie (with title screens, transitions, etc.)? Or do most people delete the originals with the feeling that DVD will be a suitable way to watch home movies for the foreseeable future?
    I just can't figure out what to do. I don't want to burn dozens of DVDs of raw footage, only to have keep up with them in a safe deposit box and have to deal with the anxiety of having to recreate movies one day (which is daunting enough now...unbelievably daunting to think about the exponential growth as time progresses).
    Hope this make sense. Reading that DVD movies are not suitable for editing due to the codec has made me realize I need to think through this before destroying all these originals as I'm finished with them.
    Thanks in advance!
    -John

    If any of your cams are miniDV, then you simply need to keep the original tapes and tape is still the safest long term archiving solution, when stored properly.
    Other cams that use flash memory, hard drives, even DVD cams, do not offer the security that tape does. If you are wanting to save those types of files, the best option would be to store them on one or two external hard drives, bearing in mind those drives could fail anytime. Back up to your back up in that case.
    Another nice thing about miniDV cams is that you can export your finished movie back to a tape also, using iMovie HD6, and have safe copies of original and finished material.
    Message was edited by: Forest Mccready

  • Best practices for initial data loads to MDM

    Hi,
       We need to load more than 300000 vendors from SAP into MDM production repository. Import server might take days to load that much if no error occurs.
    Are there any best practices for initial loads to MDM available? What considerations must be made while doing the initial loads.
    Harsha

    Hello Harsh
    With SP05 patch1 there is a file aggregation functionality in the import port. Is is supposed to optimize the import performance.
    BTW, give me your mail address and I will send you an idoc packaging paper for MDM.
    Regards,
    Goekhan

  • Kernel: PANIC! -- best practice for backup and recovery when modifying system?

    I installed NVidia drivers on my OL6.6 system at home and something went bad with one of the libraries.  On reboot, the kernel would panic and I couldn't get back into the system to fix anything.  I ended up re-installing the OS to recovery my system. 
    What would be some best practices for backing up the system when making a change and then recovering if this happens again?
    Would LVM snapshots be a good option?  Can I recovery a snapshot from a rescue boot?
    EX: File system snapshots with LVM | Ars Technica -- scroll down to the section discussing LVM.
    Any pointers to documentation would be welcome as well.  I'm just not sure what to do to revert the kernel or the system when installing something goes bad like this.
    Thanks for your attention.

    There is often a common misconception: A snapshot is not a backup. A snapshot and the original it was taken from initially share the same data blocks. LVM snapshot is a general purpose solution which can be used, for example, to quickly create a snapshot prior to a system upgrade, then if you are satisfied with the result, you would delete the snapshot.
    The advantage of a snapshot is that it can be used for a live filesystem or volume while changes are written to the snapshot volume. Hence it's called "copy on write (COW), or copy on change if you want. This is necessary for system integrity to have a consistent data status of all data at a certain point in time and to allow changes happening, for example to perform a filesystem backup. A snapshot is no substitute for a disaster recovery in case you loose your storage media. A snapshot only takes seconds, and initially does not copy or backup any data, unless data changes. It is therefore important to delete the snapshot if no longer required, in order to prevent duplication of data and restore file system performance.
    LVM was never a great thing under Linux and can cause serious I/O performance bottlenecks. If snapshot or COW technology suits your purpose, I suggest you look into Btrfs, which is a modern filesystem built into the latest Oracle UEK kernel. Btrfs employs the idea of subvolumes and is much more efficient that LVM because it can operate on files or directories while LVM is doing the whole logical volume.
    Keep in mind however, you cannot use LVM or Btrfs with the boot partition, because the Grub boot loader, which loads the Linux kernel, cannot deal with LVM or BTRFS before loading the Linux kernel (catch22).
    I think the following is an interesting and fun to read introduction explaining basic concepts:
    http://events.linuxfoundation.org/sites/events/files/slides/Btrfs_1.pdf

  • Best practices for loading swf's

    Greetings,
    Using CS5 AS2
    I'm creating a website in flash (all the files will be in one directory/folder on SharePoint) and want to make sure that what seems to be working fine is best practice.
    I have an index.swf with many buttons which will take the user to landing pages/content/other swfs. On these different buttons I have the script...
    on (release) {loadMovieNum("name.swf", 0);}                I could also do just {loadMovie("name.swf", 0);} ??
    The movie transitions nicely to name.swf and on this page I have a button that returns the user to the index.swf...
    on (release) {loadMovieNum("index.swf", 0);}   Things move back to index.swf nicely and user can chose to go to another landing page.
    It looks like I'm on the right track, bc nothing is going awry? but want to check. Am I following best practices for moving from one swf to another within a website?
    Thanks for help or confirmation!!

    loading into _level0 (and you should use loadMovieNum, not loadMovie, when loading into a level) undermines some of the benefits of a flash application:  all the assets must load with each display change and the user sees a flash instead of appearing to transition seamlessly from one display to the next.

  • Best practices for loading apo planning book data to cube for reporting

    Hi,
    I would like to know whether there are any Best practices for loading apo planning book data to cube for reporting.
    I have seen 2 types of Design:
    1) The Planning Book Extractor data is Loaded first to the APO BW system within a Cube, and then get transferred to the Actual BW system. Reports are run from the Actual BW system cube.
    2) The Planning Book Extractor data is loaded directly to a cube within the Actual BW system.
    We do these data loads during evening hours once in a day.
    Rgds
    Gk

    Hi GK,
    What I have normally seen is:
    1) Data would be extracted from APO Planning Area to APO Cube (FOR BACKUP purpose). Weekly or monthly, depending on how much data change you expect, or how critical it is for business. Backups are mostly monthly for DP.
    2) Data extracted from APO planning area directly to DSO of staging layer in BW, and then to BW cubes, for reporting.
    For DP monthly, SNP daily
    You can also use the option 1 that you mentioned below. In this case, the APO cube is the backup cube, while the BW cube is the one that you could use for reporting, and this BW cube gets data from APO cube.
    Benefit in this case is that we have to extract data from Planning Area only once. So, planning area is available for jobs/users for more time. However, backup and reporting extraction are getting mixed in this case, so issues in the flow could impact both the backup and the reporting. We have used this scenario recently, and yet to see the full impact.
    Thanks - Pawan

  • Best practice for external but secure access to internal data?

    We need external customers/vendors/partners to access some of our company data (view/add/edit).  It’s not so easy as to segment out those databases/tables/records from other existing (and put separate database(s) in the DMZ where our server is).  Our
    current solution is to have a 1433 hole from web server into our database server.  The user credentials are not in any sort of web.config but rather compiled in our DLLs, and that SQL login has read/write access to a very limited number of databases.
    Our security group says this is still not secure, but how else are we to do it?  Even if a web service, there still has to be a hole in somewhere.  Any standard best practice for this?
    Thanks.

    Security is mainly about mitigation rather than 100% secure, "We have unknown unknowns". The component needs to talk to SQL Server. You could continue to use http to talk to SQL Server, perhaps even get SOAP Transactions working but personally
    I'd have more worries about using such a 'less trodden' path since that is exactly the areas where more security problems are discovered. I don't know about your specific design issues so there might be even more ways to mitigate the risk but in general you're
    using a DMZ as a decent way to mitigate risk. I would recommend asking your security team what they'd deem acceptable.
    http://pauliom.wordpress.com

  • Best Practice for setting bind variable when application loads

    I am using JDeveloper 11.1.2.3.
    When my application loads, the first unbounded page has a table populated by a named query.
    I would like to set the parameter used by the named query when the page loads, to populate the initial data that is displayed.
    What is the best practice for a solution to this issue?

    user6003393 wrote:
    I am using JDeveloper 11.1.2.3.
    When my application loads, the first unbounded page has a table populated by a named query.
    I would like to set the parameter used by the named query when the page loads, to populate the initial data that is displayed.
    What is the best practice for a solution to this issue?Hi,
    You can set the bind variable on VO by overriding prepareSession() method in Application Module check this http://docs.oracle.com/cd/E37975_01/web.111240/e16182/bcservices.htm#sthref357
    Setting bind variable on runtime http://docs.oracle.com/cd/E37975_01/web.111240/e16182/bcquerying.htm#CHDECJHD
    Zeeshan

  • Best practice for loading config params for web services in BEA

    Hello all.
    I have deployed a web service using a java class as back end.
    I want to read in config values (like init-params for servlets in web.xml). What
    is the best practice for doing this in BEA framework? I am not sure how to use
    the web.xml file in WAR file since I do not know how the name of the underlying
    servlet.
    Any useful pointers will be very much appreciated.
    Thank you.

    It doesnt matter whether the service is invoked as part of your larger process or not, if it is performing any business critical operation then it should be secured.
    The idea of SOA / designing services is to have the services available so that it can be orchestrated as part of any other business process.
    Today you may have secured your parent services and tomorrow you could come up with a new service which may use one of the existing lower level services.
    If all the services are in one Application server you can make the configuration/development environment lot easier by securing them using the Gateway.
    Typical probelm with any gateway architecture is that the service is available without any security enforcement when accessed directly.
    You can enforce rules at your network layer to allow access to the App server only from Gateway.
    When you have the liberty to use OWSM or any other WS-Security products, i would stay away from any extensions. Two things to consider
    The next BPEL developer in your project may not be aware of Security extensions
    Centralizing Security enforcement will make your development and security operations as loosely coupled and addresses scalability.
    Thanks
    Ram

Maybe you are looking for

  • How do I print envelopes on my HP Officejet 4620 using notepad or similar?

    I tried to post my address and receiver address on note pad.  I selected #10 envelope, but the printer said I had the wrong size paper.

  • Unable to set watchdog on cFP2200 .

    I using cFP2200 for data acquisition and I want to set watchdog on the two cfP2200. Some time my code set the watchdog and some time I get time out exception in the following code .Please suggest.  CNiReal32Vector output;  CNiBoolVector status;  m_NI

  • Leopard 10.5.2 update

    I did the 10.5.2 software update on my iBook G4 and when I restarted there just the 'blue screen of death'. Ran the Leopard install disk but first aid said there was nothing wrong. I reinstalled using the 'previous system' option and it was fine runn

  • Background Image Centering and Display issues in Internet Explorer--affecting home page only??

    Hi--my web site is www.vergent.net, and for some reason, the background image will not center in Internet Explorer, but I'm having this issue only on the home page. (And only in IE. I am looking at it on IE 9). I've tried a number of workarounds, and

  • How to read data which is coming to IP

    Hi, I'm building an application that needs to read data which is coming from GPRS modem and reply to the same after some action. Through Mobile GPRS i'm sending data to our website IP. Here i need to receive that data. How can i do this..? Please any