2 Replies Latest reply on Oct 27, 2009 10:48 AM by RedOctober57

    Editing Data in modal form

    RedOctober57 Level 1

      I have an mxml for my project, in which I have a DataGrid with a few fields, just enough to locate a desired record.  When I double click on the item in the DataGrid, a modal form pops up, populated with the data in all the fields of the same record.  So far, so good.  However, now when I try to edit any data in any field, I get an error message:

       

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at mx.containers::TabNavigator/keyDownHandler()[E:\dev\gumbo_beta2\frameworks\projects\frame work\src\mx\containers\TabNavigator.as:904]

       

      I don't have a keyDownHandler on my TabNavigator.

       

      My project is fairly small and a knowledgable person would probably be able to see my mistake in 10 seconds or less if they reviewed my code.  A zip file with my code is attached.

       

      If some one could take a look, and post the errorneous line in the reply... then everyone in the forum could benefit.

       

      I am making progress thanks to the excellent examples and instructions provided at:

       

      http://sujitreddyg.wordpress.com/flash-builder-4/

       

      I got a little demo of my own working just like in the instructions.  I had to rebuild my test project from scratch several times.. I think the FB 4 b 1 stuff was interfering with the FB 4 b2 way of doing things. However now, I am trying to build my test project in the way that my real project will work.. and that is... all detail forms will be opened in a modal window, edited, commited and then closed.

        • 1. Re: Editing Data in modal form
          Flex harUI Adobe Employee

          For some reason, zip files often get corrupted.  Cut and paste the popup form and the code that pops it up.  Maybe you didn't use PopUpManager to pop it up?

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: Editing Data in modal form
            RedOctober57 Level 1

            PROBLEM:  MODAL "frmSBJ" FORM crashes when I try to edit the text in a TextInput.  (See exact error text in previous post)

             

            In the baa_ria.mxml: ------------------------------------------------------

             

                <fx:Script>
                    <![CDATA[

                           ...

                        import components.*;
                        import mx.managers.PopUpManager;

                           ...

             

             

                        protected function grdSBJs_itemDoubleClickHandler(event:ListEvent):void
                        {
                            show_frmSBJ();               
                        }
                       
                        public function show_frmSBJ():void
                        {
                            var pop:frmSBJ = frmSBJ(PopUpManager.createPopUp(this, frmSBJ, true));
                            pop.bAA_SBJ = grdSBJs.selectedItem as BAA_SBJ;
                            PopUpManager.centerPopUp(pop);                                          
                        }

             

             

            In the "components" folder, frmSBJ.mxml: ---------------------------------------------------------

             

            <?xml version="1.0" encoding="utf-8"?>
            <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
                             xmlns:s="library://ns.adobe.com/flex/spark"
                             xmlns:mx="library://ns.adobe.com/flex/halo"
                             width="600" height="506"
                             xmlns:valueObjects="valueObjects.*"
                             xmlns:baa_data_svc="services.baa_data_svc.*">
                <s:layout>
                    <s:BasicLayout/>
                </s:layout>
               
                <fx:Script>
                    <![CDATA[
                        import mx.controls.Alert;
                        import mx.managers.PopUpManager;

             

                        protected function btnDone_clickHandler(event:MouseEvent):void
                        {
                            // TODO: Refresh the grdSBJs somehow
                            PopUpManager.removePopUp(this);
                        }

             

             

             

                        protected function btnCommit_clickHandler(event:MouseEvent):void
                        {
                            updt_SBJResult.token = baa_data_svc.updt_SBJ(bAA_SBJ);
                        }

             

                    ]]>
                </fx:Script>
               
                <fx:Declarations>
                    <valueObjects:BAA_SBJ id="bAA_SBJ"/>
                    <mx:DateFormatter id="dfISO" formatString="YYYY-MM-DD"/>
                    <mx:DateFormatter id="tfHMS" formatString="HH:MM:SS"/>
                    <s:CallResponder id="updt_SBJResult"/>
                    <baa_data_svc:Baa_data_svc id="baa_data_svc" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
                </fx:Declarations>

             

                <s:Panel x="15" y="9" width="564" height="465" id="pnlMain" title="Subject Name">
                    <s:Group x="10" y="377" width="544" height="41" id="grpButtonBar">
                        <s:Button x="309" y="10" label="Commit" id="btnCommit" click="btnCommit_clickHandler(event)" />
                        <s:Button x="386" y="10" label="Undo" id="btnUndo"/>
                        <s:Button x="464" y="10" label="Done" click="btnDone_clickHandler(event)" id="btnDone"/>
                    </s:Group>
                    <mx:TabNavigator x="6" y="8" width="548" height="361" id="tnvSBJ" creationPolicy="all">
                        <s:NavigatorContent label="Properties" width="100%" height="100%" id="nvcProperties">
                            <mx:Form x="126" y="5">
                                <mx:FormItem label="SBJ_NM">
                                    <s:TextInput id="sBJ_NMTextInput" text="@{bAA_SBJ.SBJ_NM}"/>
                                </mx:FormItem>
                                <mx:FormItem label="SBJ_DOB">
                                    <mx:DateField id="sBJ_DOBDateField" selectedDate="@{bAA_SBJ.SBJ_DOB}"/>
                                </mx:FormItem>
                                <mx:FormItem label="SBJ_ID">
                                    <s:TextInput id="sBJ_IDTextInput" text="@{bAA_SBJ.SBJ_ID}"/>
                                </mx:FormItem>
                                <mx:FormItem label="NOTE">
                                    <s:TextArea id="nOTETextInput" text="@{bAA_SBJ.NOTE}"/>
                                </mx:FormItem>
                            </mx:Form>
                        </s:NavigatorContent>
                        <s:NavigatorContent label="Meta-data" width="100%" height="100%" id="nvcMetaData">
                            <mx:Form x="117" y="25">
                                <mx:FormItem label="SRC_SYS_NM">
                                    <mx:Text id="sRC_SYS_NMText" text="{bAA_SBJ.SRC_SYS_NM}"/>                       
                                </mx:FormItem>
                                <mx:FormItem label="SRC_SYS_GUID">
                                    <mx:Text id="sRC_SYS_GUIDText" text="{bAA_SBJ.SRC_SYS_GUID}"/>
                                </mx:FormItem>
                                <mx:FormItem label="OBJ_GUID">
                                    <mx:Text id="oBJ_GUIDText" text="{bAA_SBJ.OBJ_GUID}"/>
                                </mx:FormItem>
                                <mx:FormItem label="CDT">
                                    <mx:Text id="cDTText" text="{dfISO.format(bAA_SBJ.CDT)}"/>
                                </mx:FormItem>
                                <mx:FormItem label="CTM">
                                    <mx:Text id="cTMText" text="{tfHMS.format(bAA_SBJ.CTM)}"/>
                                </mx:FormItem>
                                <mx:FormItem label="CBY">
                                    <mx:Text id="cBYText" text="{bAA_SBJ.CBY}"/>
                                </mx:FormItem>
                                <mx:FormItem label="MDT">
                                    <mx:Text id="mDTText" text="{dfISO.format(bAA_SBJ.MDT)}"/>
                                </mx:FormItem>
                                <mx:FormItem label="MTM">
                                    <mx:Text id="mTMText" text="{tfHMS.format(bAA_SBJ.MTM)}"/>
                                </mx:FormItem>
                                <mx:FormItem label="MBY">
                                    <mx:Text id="mBYText" text="{bAA_SBJ.MBY}"/>
                                </mx:FormItem>
                            </mx:Form>
                        </s:NavigatorContent>
                    </mx:TabNavigator>
                </s:Panel>       
            </s:Group>

             

            Thanks for your help pointing out where in this code I am going wrong.