8 Replies Latest reply on Jan 19, 2009 6:15 PM by ntsiii

    edit/delete/insert forms using php

    dabomb_gent
      Hi,

      I have created an application that will allow me to edit/delete/insert data to my database using php.

      The functions work. But when I click on a tab i get an error like this:

      ypeError: Error #1009: Cannot access a property or method of a null object reference.
      at StoreManagement/runFeed()[C:\adobeStoreManagement\StoreManagement\src\StoreManagement.mxm l:26]
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.core::UIComponent/dispatchEvent()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\co re\UIComponent.as:9051]
      at mx.containers::ViewStack/dispatchChangeEvent()[E:\dev\3.0.x\frameworks\projects\framework \src\mx\containers\ViewStack.as:1165]
      at mx.containers::ViewStack/commitProperties()[E:\dev\3.0.x\frameworks\projects\framework\sr c\mx\containers\ViewStack.as:672]
      at mx.containers::TabNavigator/commitProperties()[E:\dev\3.0.x\frameworks\projects\framework \src\mx\containers\TabNavigator.as:504]
      at mx.core::UIComponent/validateProperties()[E:\dev\3.0.x\frameworks\projects\framework\src\ mx\core\UIComponent.as:5670]
      at mx.managers::LayoutManager/validateProperties()[E:\dev\3.0.x\frameworks\projects\framewor k\src\mx\managers\LayoutManager.as:519]
      at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\3.0.x\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:669]
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.core::UIComponent/callLaterDispatcher2()[E:\dev\3.0.x\frameworks\projects\framework\sr c\mx\core\UIComponent.as:8460]
      at mx.core::UIComponent/callLaterDispatcher()[E:\dev\3.0.x\frameworks\projects\framework\src \mx\core\UIComponent.as:8403]

      Also the first time I click on the edit program link it doesnt show any data in the combo. Then when I click on new store. It fills up the comboboxes. When I go back to the edit program tab. It now also has the data inside the combobox.

      When I add a new program, store or categorie. It says operation succesfull. But the new program is not added to the new comboboxes. I have to close the browser and rerun the application. Then it shows the entered value inside the comboboxes.

      I have attached all my code for this application, any help would be greatly appreciated. Also could you advise me on what is the best approach to do this?

      With friendly regards,
      Thomas
        • 1. Re: edit/delete/insert forms using php
          ntsiii Level 3
          A few things:
          * Do not use lastResult in AS code. It is intended for use in binding expressions only. I suspect that it is the cause of your error, since it will not yet exist where you are trying to reference it.
          * All data service calls in Flex are asynchronous. this means you can *never* access the result data in the same function you call send(), as you are attempting.
          * Use a result handler for all HTTPService calls
          * Your data model methodology is *good*, using instance vars to hold ArrayCollections, and binding to those vars. Just set the vars in a result handler, instead of in the send function
          * the default resultFormat of HTTPService is object. This causes Flex to convert the HTTPService XML into a tree of dynamic objects. While it provides a quick start, it has long term drawbacks. I advise setting resultFormat="e4x", so that youcan use the powerful e4x XML API on your data.



          • 2. Re: edit/delete/insert forms using php
            dabomb_gent Level 1
            Thank you for your reply.

            I changed my code to use a resultHandler. And I access the result data in another function.

            It still does not update the data of the comboboxes. If for example I delete one value and click another tab. The data is not being refreshed.

            Is there any reason why it is not refreshing?
            • 3. Re: edit/delete/insert forms using php
              ntsiii Level 3
              So, you are saying that you have traced the contents of the resultEvent.result object and see the data you expect?

              Does any of your data display? Is it just the ComboBoxes that are a problem?

              One suggestion, implement one of the main data properties in a cpmponent as a setter/getter function pair. Debug the data in the setter to see if you have the data where you need it.
              • 4. edit/delete/insert forms using php
                dabomb_gent Level 1
                deleted sry duplicate post
                • 5. Re: edit/delete/insert forms using php
                  dabomb_gent Level 1
                  Hi,

                  thanks for helping me out ! I found the answer in one of your other posts. The php page was cached by ie. I used method="post" and know my data is getting refreshed after I click on a tab.

                  I know ran into another problem with my comboboxes.

                  I use the selectedIndex="{storeCombo.selectedItem.storecat}" This will select the index that equals the storecat id. However my id's are not stored in an ordered fashion in the database. Thus this is selecting the wrong selectedIndex.

                  program looks like this
                  id=1 name=prog1
                  id=12 name=prog2
                  id=13 name=prog3

                  I am not sure if you understand what I mean but I need something along the lines of :

                  selectedIndex="{index of program that equals storeCombo.selectedItem.storecat}"
                  • 6. Re: edit/delete/insert forms using php
                    ntsiii Level 3
                    Then you will need to loop over the dataProvider, and compare the value of the appropriate property to the value of storeCombo.selectedItem.storecat. When you have a match, use that loop index to set the DataGrid.selectedIndex, and break; out of the loop.

                    Tracy
                    • 7. Re: edit/delete/insert forms using php
                      Level 7

                      "ntsiii" <tspratt@lariatinc.com> wrote in message
                      news:gl3850$juj$1@forums.macromedia.com...
                      > Then you will need to loop over the dataProvider, and compare the value of
                      > the
                      > appropriate property to the value of storeCombo.selectedItem.storecat.
                      > When
                      > you have a match, use that loop index to set the DataGrid.selectedIndex,
                      > and
                      > break; out of the loop.

                      Couldn't you use a cursor instead of a loop?


                      • 8. Re: edit/delete/insert forms using php
                        ntsiii Level 3
                        Amy, are there befnefits to using a collection cursor over looping? Loops are second nature to me and I have never used a cursor, so I am looking to learn.