11 Replies Latest reply on Jan 12, 2009 12:04 PM by G009

    Call out side flex

    G009 Level 1
      Hello guys. I am working on a project in flex. What i want to do is, i want to send a request from flex form and after i send request i want to get the response back to some page other than flex. I am following MVC. And m using J2EE on back-end. I can successfully send and receive data from flex. But now i dont want get my responce back to flex, instead JSP or html is preferable. Please let me know if this is possible.
        • 1. Re: Call out side flex
          Michael Borbor Level 4
          You could use the Flex/AJAX bridge or the externalinterface to pass code from flex to javascript
          • 2. Re: Call out side flex
            Madhav Subedi Level 4
            use ExternalInterface.call("jsFunction","param") method.
            • 3. Re: Call out side flex
              G009 Level 1
              thx guys....i will check which solution works best for me....and will post back again....
              • 4. Re: Call out side flex
                G009 Level 1
                Ok here is my problem... i am working on proj with MVC and J2EE framework. Flex is my view. Struts is my controller. Now if i send request from view i.e. flex, i want my struts to decide which page to display to user. But flex is taking control and since flex sent request flex expects responce. Now after i sent request from flex i want struts to decide and load page. I did that in struts-config.xml. But its not working and flex window keep on displaying. I dont know why it is coming like this. Plz help me with this. Also i went though the solution which are give above. But m not sure how that solution will solve my problem.
                • 5. Re: Call out side flex
                  Level 7

                  "G009" <webforumsuser@macromedia.com> wrote in message
                  news:gk5blt$i$1@forums.macromedia.com...
                  > Ok here is my problem... i am working on proj with MVC and J2EE framework.
                  > Flex
                  > is my view. Struts is my controller. Now if i send request from view i.e.
                  > flex,
                  > i want my struts to decide which page to display to user. But flex is
                  > taking
                  > control and since flex sent request flex expects responce. Now after i
                  > sent
                  > request from flex i want struts to decide and load page. I did that in
                  > struts-config.xml. But its not working and flex window keep on displaying.
                  > I
                  > dont know why it is coming like this. Plz help me with this. Also i went
                  > though
                  > the solution which are give above. But m not sure how that solution will
                  > solve
                  > my problem.

                  You'll probably need to either send the request from the HTML wrapper so
                  that it acts as a normal Post request, or you'll need to send a response
                  back to Flex and let Flex make the change.

                  HTH;

                  Amy


                  • 6. Re: Call out side flex
                    G009 Level 1
                    oh cool....it seems html wrapper will work cool for me....thx a lot....
                    • 7. Re: Call out side flex
                      G009 Level 1
                      ok but how to send request from HTML wrapper....so that it will act as normal post request..
                      • 8. Re: Call out side flex
                        run,ryan! Level 3
                        navigateToURL will help you
                        • 9. Re: Call out side flex
                          Level 7

                          "run,ryan!" <webforumsuser@macromedia.com> wrote in message
                          news:gk66gv$5ic$1@forums.macromedia.com...
                          > navigateToURL will help you

                          Or use a hidden form and javascript to send it. But ryan is right--his
                          method is probably easier :-)


                          • 10. Re: Call out side flex
                            G009 Level 1
                            I tried using navigateToURL()...its not working. Following is my flex code. can someone please show me how to send this data to struts. i.e. struts-config.xml.

                            <mx:Form id="form1">
                            <mx:FormItem label="User Name" required="true">
                            <mx:TextInput id="userName" width="200"/>
                            </mx:FormItem>
                            <mx:FormItem label="Password" required="true">
                            <mx:TextInput id="password" width="200"/>
                            </mx:FormItem>
                            <mx:FormItem>
                            <!--mx:Button label="Log In" click="submitForm()"/-->
                            <mx:Button label="Log In" click="sendForm()"/>
                            </mx:FormItem>
                            </mx:Form>

                            Please tell me what should i write in sendForm();
                            My struts-config.xml is as follows. My form should send login.do request so that it can be handled.

                            <?xml version="1.0" encoding="ISO-8859-1" ?>
                            <!DOCTYPE struts-config PUBLIC
                            "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
                            " http://struts.apache.org/dtds/struts-config_1_3.dtd">
                            <struts-config>

                            <form-beans>

                            <form-bean type="example.forms.LoginForm" name="LoginForm"/>

                            </form-beans>

                            <!-- ==== Action Mapping Definitions ==== -->
                            <action-mappings>

                            <action path="/login" type="example.action.LoginAction" validate="false" scope="request" input="/login.html" name="LoginForm">
                            <forward name="success" path="/main.jsp"/>
                            <forward name="failure" path="/loginfailed.jsp"/>
                            </action >
                            </action-mappings>

                            </struts-config>
                            • 11. Re: Call out side flex
                              G009 Level 1
                              ok guys i got the solution.....
                              Flex->struts->JSP/HTMl any page
                              private function sendForm():void{

                              var str:String="login.do";
                              var link:URLRequest=new URLRequest(str);
                              var variables:URLVariables = new URLVariables();
                              variables.userName = userName.text;
                              variables.password = password.text;
                              link.data = variables;
                              navigateToURL(link,'_self');

                              }

                              Since it took so much trouble for me to do this code. I am posting it so that it will be helpful for others. Lol. Thanks to everyone.