6 Replies Latest reply on Aug 24, 2006 6:56 PM by benotom

    Server side event

    benotom
      Hello,
      I am new to flex. I am trying to do a flex page that has a data grid and a button. When the user click on the button, I want the event to somehow get propagated to the server and do some processing on the server side and change the values in the datagrid (without doing a page refresh). I cannot use Flex Data services.
      With this restriction, can someone please tell me how to achieve this?
      thank you!
        • 1. Re: Server side event
          ntsiii Level 3
          Sure.

          Use one of the three "RPC" protocols, WebService, HTTPService, or RemoteObject.

          What is your server-side platform of choice?

          Tracy
          • 2. Re: Server side event
            benotom Level 1
            I tried http service with URL pointing to an xml document.
            The data grid is initially populated with data from XML. When user click on a button, I want the event to propagate to the server where I can act on this event, change the data in XML and somehow get this data refreshed on the UI.
            So when the data changes on the XML, somehow I have to push this data to the client. How will flex know if XML file got updated with new data on the server?
            thank you!
            • 3. Re: Server side event
              ntsiii Level 3
              You can't "push" data to the client without FDS. Well, you could set up as TCP socket connection, but that is a bit difficult.

              Is the processing of the data you need to do necessarily asynchronous?

              An HTTPService call can wait for normal server-side processing to complete and return the modified data, unless this process is very slow. I do this regularly: Send data to the server, process it, and send back a result. It is fairly simple.

              What is your server-side platform of choice?

              Tracy
              • 4. Re: Server side event
                benotom Level 1
                I am looking for how to do exactly what you have already done: Send data to the server, process it, and send back a result.
                I need to do this using HTTPService. This needs to be synchronous. Can you please let me know how to do this?

                We have a proprietary framework which is a MVC based design. The server side has something very similar to Java. We have a web server similar to Tomcat, but not J2EE. So I can't use FDS.
                Thank you!
                • 5. Re: Server side event
                  ntsiii Level 3
                  As long as your server side can accept an HTTP post or get request, read the request parameters, and respond with XML, it does not matter how that happens.

                  I'd start with a "helloWorld" level app to establish the techniques before starting on the main app:

                  * Create a server url destination that will take a single parameter, "whatever". Have it use that parameter value to build an xml string say:
                  <root><response>You sent me the value 'something' in the request parameter 'whatever'</response></root>

                  * Test it in a browser

                  *Create a Flex app that uses HTTPService (resultFormat="e4x") to acces this url, sending {whatever:"something"} in the request object. Use a result handler function to verify and process the return.

                  That's it.

                  Give it a try and post back if you have any specific issues.

                  Tracy
                  • 6. Re: Server side event
                    benotom Level 1
                    Thank You! It worked.