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

    Trouble with Databases and putting data into them

    FrankBHill

      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!

       

      Frank

        • 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"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx"
            skinClass="skins.HPAppSkin"
            xmlns:views="views.*"
            xmlns:categoryservice="services.categoryservice.*"
            xmlns:forms="forms.*">
            <fx:Script>
              <![CDATA[
                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);
                  trace(createCategoryResult.token.result);
                }

           

                protected function myForm_insertHandler(event:CategoryEvent):void
                {
                  createCategory(event.category);
                  trace(event.category.category);
                }

           

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

           

              ]]>
            </fx:Script>
            <s:states>
              <s:State name="default"/>
              <s:State name="insert"/>
            </s:states>
            <fx:Declarations>
              <s:CallResponder id="getAllCategoryResult"/>
              <categoryservice:CategoryService id="categoryService"
                fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
                showBusyCursor="true"/>
              <s:CallResponder id="createCategoryResult" result="createCategoryResult_resultHandler(event)"/>
            </fx:Declarations>
            <s:Panel title="Categories" title.insert="Insert New Category">
              <views:CategoryGrid
                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)"/>
              <s:controlBarContent>
                <s:Button
                  label="Insert Category" click="currentState='insert'"
                  includeIn="default"/>   
              </s:controlBarContent>
            </s:Panel>
          </s:Application>

           

           

           

          ______Form_______

          <?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/mx" xmlns:valueObjects="valueObjects.*">
           
            <fx:Metadata>
              [Event(name="insert", type="events.CategoryEvent")]
              [Event(name="cancel", type="flash.events.Event")]
            </fx:Metadata>

           

            <fx:Script>
              <![CDATA[
                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;
                  dispatchEvent(ev);
                }
                protected function cancelBtn_clickHandler(event:MouseEvent):void
                {
                  dispatchEvent(new Event("cancel"));
                }
            
              ]]>
            </fx:Script>
           
            <fx:Declarations>
              <valueObjects:Category id="category"/>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
            </fx:Declarations>
            <mx:Form defaultButton="{submitBtn}">
              <mx:FormItem label="Category">
                <s:TextInput id="categoryTextInput" text="{category.category}"/>
              </mx:FormItem>
              <mx:FormItem label="Description">
                <s:TextInput id="descriptionTextInput" text="{category.description}"/>
              </mx:FormItem>
              <mx:FormItem direction="horizontal">
              <s:Button id="submitBtn" label="Submit" click="submitBtn_clickHandler(event)"/>
               <s:Button id="cancelBtn" label="Cancel" click="cancelBtn_clickHandler(event)"/>     
              </mx:FormItem>
            </mx:Form>
           
          </s:Group>

          • 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
                fiy47

                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