4 Replies Latest reply on Aug 21, 2011 8:01 AM by fiy47

    Trouble with Databases and putting data into them


      I have been working on this application for about three days and choose the tool because I thought database connectivity was super simple. Provided I didn't need to anything but get data or add data I could use the WYSIWG editor to drag and drop items to make the connections. Every single sample, book, tutorial or helpful guide I have found on the internet does the same thing.


      I can always get data from the database but when I press the submit button using their examples they all fail. Plus, most of these from the beta 2 and I have not found anything useful for FB4 (Release), PHP and MySQL.


      I can provide whatever information is need to help me understand I am hoping for answer, link to current tutorial or article full explaining how it works using the automated system or confirmation it does work use this other technology that works better.


      Anything you might have would be super thanks!



        • 1. Re: Trouble with Databases and putting data into them
          FrankBHill Level 1

          I have some more information that I think might be helpful. I am following the samples on lynda.com for their Flex 4 and Flash Builder 4 Essential training. Attached is the code that I created as part of the example. When I press the submit button it says in the status bar transferring data to localhost like it is stuck. When I trace createCategoryResult.token.result it shows null in the console. Then I thought why not debug. I put my breakpoint on the line that calls the createCategory method. When I viewed the variables I was able to see the form picked my up items then dropped them into the object. Further, when I debugged createCategoryResult.token = categoryService.createCategory(item); line I found that it was giving me back a lot of undefined. I am not sure where I am going wrong. Can anyone confirm if the Flex and Action Script is correct or point me where to debug and what to look for. I really appreciate any assistance available.


          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                import events.CategoryEvent;
                import mx.controls.Alert;
                import mx.events.FlexEvent;
                import mx.rpc.events.ResultEvent;
                import valueObjects.Category;
                protected function categoryGrid_creationCompleteHandler(event:FlexEvent):void
                  getAllCategoryResult.token = categoryService.getAllCategory();
                protected function createCategory(item:Category):void
                  createCategoryResult.token = categoryService.createCategory(item);


                protected function myForm_insertHandler(event:CategoryEvent):void


                protected function createCategoryResult_resultHandler(event:ResultEvent):void
                  myForm.category = new Category();
                  currentState = "default";
                  Alert.show("Your data was inserted", "Success");


              <s:State name="default"/>
              <s:State name="insert"/>
              <s:CallResponder id="getAllCategoryResult"/>
              <categoryservice:CategoryService id="categoryService"
                fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
              <s:CallResponder id="createCategoryResult" result="createCategoryResult_resultHandler(event)"/>
            <s:Panel title="Categories" title.insert="Insert New Category">
                width="700" height="250"
                includeIn="default" id="categoryGrid" creationComplete="categoryGrid_creationCompleteHandler(event)" dataProvider="{getAllCategoryResult.lastResult}"/>
              <forms:CategoryForm2 id="myForm" includeIn="insert"
                cancel="currentState='default'" insert="myForm_insertHandler(event)"/>
                  label="Insert Category" click="currentState='insert'"





          <?xml version="1.0" encoding="utf-8"?>
          <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:valueObjects="valueObjects.*">
              [Event(name="insert", type="events.CategoryEvent")]
              [Event(name="cancel", type="flash.events.Event")]


                import events.CategoryEvent;
                protected function submitBtn_clickHandler(event:MouseEvent):void
                  category.category = categoryTextInput.text;
                  category.description = descriptionTextInput.text;
                  var ev:CategoryEvent = new CategoryEvent("insert");
                  ev.category = this.category;
                protected function cancelBtn_clickHandler(event:MouseEvent):void
                  dispatchEvent(new Event("cancel"));
              <valueObjects:Category id="category"/>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
            <mx:Form defaultButton="{submitBtn}">
              <mx:FormItem label="Category">
                <s:TextInput id="categoryTextInput" text="{category.category}"/>
              <mx:FormItem label="Description">
                <s:TextInput id="descriptionTextInput" text="{category.description}"/>
              <mx:FormItem direction="horizontal">
              <s:Button id="submitBtn" label="Submit" click="submitBtn_clickHandler(event)"/>
               <s:Button id="cancelBtn" label="Cancel" click="cancelBtn_clickHandler(event)"/>     

          • 2. Re: Trouble with Databases and putting data into them
            FrankBHill Level 1

            I went through another tutorial this one even more simple and using just the basics.

            http://www.flepstudio.org/forum/flex-builder-3-eng/6089-connecting-flex-4-zend-using-flash -builder-4-a.html


            When I run the application that data comes into the DataGrid without issue.


            When I click the Submit button I see in the status bar of the browser Transferring data from localhost... and it hangs there and does nothing.


            Has anyone else experienced this issue?


            Most recent version of WAMP with no modifications.

            Basic Zend installed by Adobe Flash Builder 4 1.10.1 I believe


            There really seems like it should be working but for some reason it is not!

            • 3. Re: Trouble with Databases and putting data into them
              Sameer Bhatt Adobe Employee

              You can try these steps -

              1. Put a breakpoint in createCategoryResult_resultHandler() and see whether it is getting hit. If it is getting hit, then your form is getting submitted properly.

              Otherwise/additionally -

              2. Add a fault handler to createCategoryResult and see whether there is any problem while performing the requested operation.

              3. Enable Network Monitor and see whether the data flows are happening as expected.

              • 4. Re: Trouble with Databases and putting data into them

                Please Debug it step by step, i never change anything, just debug it,


                The breake poit is at " createCategoryResult.token = categoryService.createCategory(item);"


                and then click the button "step into", it is OK.


                I don't know why, it' OK now, it took me for one day.


                If you have anyquestion, send email: fiy47@126.com