-1

I am stuck and need to figure out how to send my form data to MySQL. I have the form already created.

script in my group component...

protected function button_clickHandler(event:MouseEvent):void
            {
                customers.firstname = firstnameTextInput.text;
                customers.lastname = lastnameTextInput.text;
            }

form in my group component...

<s:Form defaultButton="{button}">
        <s:FormItem label="Firstname">
            <s:TextInput id="firstnameTextInput" text="{customers.firstname}"/>
        </s:FormItem>
        <s:FormItem label="Lastname">
            <s:TextInput id="lastnameTextInput" text="{customers.lastname}"/>
        </s:FormItem>
        <s:Button id="button" label="Submit" click="button_clickHandler(event)"/>
    </s:Form>

script in my main app...

            import mx.controls.Alert;
            import mx.events.FlexEvent;

            import valueObjects.Customers;

            protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
            {
                getAllCustomersResult.token = customersService.getAllCustomers();
            }


            protected function createCustomers(item:Customers):void
            {
                createCustomersResult.token = customersService.createCustomers(item);
            }

and my component in my main app...

<forms:AddCustomerForm id="addCustomerForm"/>

From my understanding, what I have written so far has not sent the data to the sever yet? Not sure what to do next.

Oh, and this in my main app...

<fx:Declarations>
        <s:CallResponder id="getAllCustomersResult"/>
        <customersservice:CustomersService id="customersService"
                                           fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
                                           showBusyCursor="true"/>
        <s:CallResponder id="createCustomersResult"/>

    </fx:Declarations>

I am using WAMP

ketan
  • 19,129
  • 42
  • 60
  • 98
Omgabee
  • 97
  • 10
  • I'd like to add that I can get the data with no problem....I can display the MySQL data (that I've manually entered) in my data grid on my application. – Omgabee Oct 03 '14 at 16:41
  • Few questions: Do you have customerService defined somewhere? If so… what type of object is it? What's the server side technology you're using? – Clintm Oct 03 '14 at 17:22
  • I updated my question...I believe this is where it is defined, in my declarations. And updated to say I'm using WAMP. edit: I should also say...all of this code was generated for me in flex – Omgabee Oct 03 '14 at 17:34
  • If you're doing AMF based stuff you can use Charles Proxy to see the AMF calls going back and forth between your browser (flex/flash) and the web server. – Clintm Oct 03 '14 at 17:34
  • What type of object is CustomersService? What does it extend? Are you using the AMFPHP? – Clintm Oct 03 '14 at 17:38
  • I could be saying this completely wrong....but I believe CustomersService is the class created by flex for me when I connected to the database... it contains the functions for the MySQL php like the createCustomers() and getAllCustomers()....im already using the getAllCustomers() with success and retrieving the one row of data that I already have entered in my database on my WAMP server...so it's working, I just can't figure out how to create a row in the table using the createCustomers() function... – Omgabee Oct 03 '14 at 17:51

1 Answers1

0

OK… I think I understand now. You were following this tutorial or something (exactly) like it?

http://www.youtube.com/watch?v=0fSe2TIbWXc

I think your question is… how do I call the service in the parent application from my child component?

You could create a variable in your child component and pass in your service.

public var customerService:CustomersService;

And then in your click handler you can call:

protected function button_clickHandler(event:MouseEvent):void
{
  customers.firstname = firstnameTextInput.text;
  customers.lastname = lastnameTextInput.text;
}

And when I say "pass in your service" I mean to the tag you have declared in your main application:

<controls:YourFormComponent id="whatever" customerService="{customerService}" />

There are other (better) ways to reference the service… but this should do what you want for now.

Let me know if that helps.

Clintm
  • 4,505
  • 3
  • 41
  • 54
  • No, I think I'm in over my head. lol I'm gonna go practice some more simpler tasks. Thanks for your help! Dx – Omgabee Oct 03 '14 at 19:55
  • ok… if you want to share your client side code… I'm sure we could make it work – Clintm Oct 03 '14 at 20:11