15 Replies Latest reply on Jul 9, 2009 6:58 AM by Jerry62712

    Serveral questions

    Jerry62712 Level 1

      Normally I wouldn't put in multiple questions in one thread, but given it takes about an hour for this box to open up - at least for me - there isn't enough time in a day to post different threads.  Three questions, three hours and presumely 3 hours for a reply and there is the day shot.

       

      1.  How do I determine if a node exists in an XML variable?

           parseXML:XML may or may not have various nodes in it.  Testing for null or = "" or > "" won't do the trick.

       

      2. Is it possible to add a query string into the IDE for testing?

          Project | Properties | Run/Debug Settings seemed like a logical place to put in debug stuff, but if you change this:

          C:\Flex Builder 3\FSCalc\FSCalc\bin-debug\FSCalc.html (default) to

          C:\Flex Builder 3\FSCalc\FSCalc\bin-debug\FSCalc.html?xml=<?xml version="1.0" encoding="UTF-8" ?><FSParm><GrossMonthlyEarnedIncome>2000</GrossMonthlyEarnedIncome><GrossMonthlyOtherInco me>694</GrossMonthlyOtherIncome><HouseholdSize>6</HouseholdSize><QualifyingMember>true</Qu alifyingMember><SimplifiedProcessingUnitInd>true</SimplifiedProcessingUnitInd><DependentCa reCostsAmt>500</DependentCareCostsAmt><NumberOfChildrenUnder2></NumberOfChildrenUnder2><Nu mberOfChildrenOver2>1</NumberOfChildrenOver2><CourtOrderedSupportAmt>300</CourtOrderedSupp ortAmt><MedicalExpenseAmt>250</MedicalExpenseAmt><MonthlyRentOrMortgageAmt>250</MonthlyRen tOrMortgageAmt><MonthlyInsuranceAndTaxAmt>0</MonthlyInsuranceAndTaxAmt><UtilityType>liheap </UtilityType><TotalAssets>2999</TotalAssets></FSParm>

         you get an error that the file can't be found.  What file I'm not sure.  In the above, only "HouseholdSize" is required thus #1.

       

      3. How do you output a stream?

          Our current system written in java has these three lines:


         OutputStreamWriter out = new  OutputStremeWriter(response.getOutputStream());
         out.write(responseString);
         out.close();

         This will take a stream of data in XML format and write it out.  The program that called our application will read it.

      Thanks,
      Jerry
        • 1. Re: Serveral questions
          meshgraphics Level 2

          You are putting the text of an xml file in the url parm?

          I didn't know you could do that.

           

          • 2. Re: Serveral questions
            rtalton Level 4

            Answer for #1:

            Using the "hasOwnProperty" method  allows you to test an XML object (a node) for a given property (an element).

            • 3. Re: Serveral questions
              Jerry62712 Level 1

              Wonder of wonders.  This box came up in under 5 minutes.

               

              Yes, I am getting the XML stuff as a query string in the url of the application.  It took several weeks to find anyone that knew how to do this, but thanks to the helpful community it was done.  I'll be happy to pass on the class I made to get the query stream and parse it to individual elements.  That is the one I'm working on right now, however.  Trying to make sure the element exits.  I have a pointer that I'll be testing this morning and hopefully will be able to make the class more bullet proof.

               

              What I have to do next is pass out the results of the application as an XML stream.  Just as background, we have an application that finds food stamp potential benefits.  It's on the web.  But this can also be invoked from a program and that program needs the results - thus the output stream I'm trying to figure out how to create.  That program is based on someone dialing into it over the phone.  They enter some data and then the program sends it to us and we send the results back to the program.  That's what the third question is all about.

              • 4. Re: Serveral questions
                Jerry62712 Level 1

                Whoops.  I see that my reply did show up.  At my end I got a timeout on the server so I didn't know if it had worked.

                • 5. Re: Serveral questions
                  rtalton Level 4

                  As far as getting data out of Flex... I think I understand now that you are trying to do it by putting the XML into the url, right? You don't want to pass the XML back into a database or anything? What would be consuming the XML results from Flex?

                  • 6. Re: Serveral questions
                    meshgraphics Level 2

                    It looks like you're testing on the localhost webserver.  You might want to debug on the webserver.  Upload the files to webserver and change the debug url to "myInternet.com/myApp/bin-debug/myApp.html?debug=true"

                     

                    Something like that.

                    • 7. Re: Serveral questions
                      Jerry62712 Level 1

                      Another wonder - I started the reply and was going to go on break when this window opened in under 1 (yes - ONE) minute.

                       

                      I liked your solution best of those I found.  The other two also worked, but this seems more staightforward to me.  We can mark question 1 as done!

                       

                      Thanks for your time.

                      • 8. Re: Serveral questions
                        Jerry62712 Level 1

                        Yes, that is correct.  Nothing is going to any file or database.  The program that calls our application passes us an XML string in the URL as a query string.  We do calculations based on their input and then we (question #3) have to send them back a string of data in an XML format that they can then use.

                         

                        Backstory:

                        Someone calls a phone number and are asked some questions.  That program will take the results of the numbers they punch into the phone (they may do voice recognization as well) and calls our application via a url with a query string formatted as XML.  We then return a string to them and they convert it to spoken words and the guy that called gets his answer.

                        • 9. Re: Serveral questions
                          rtalton Level 4

                          One more question: Referring to the other "program" you are using---How would you get the string out of the url of the Flex app's browser? I'm assuming this is a Flex app in a browser, NOT an AIR app.

                          • 10. Re: Serveral questions
                            Jerry62712 Level 1

                            I test from Flex.  It opens a browser with the application.  I can start a TOMCAT session, but I don't know how I would see the console or step through the code at that point.

                            • 11. Re: Serveral questions
                              Jerry62712 Level 1

                              My program is a Flex application.  I have no idea of what the one that invokes me is written in.

                               

                              They invoke my URL including a query string that is formatted as XML data.  I can now get that data and parse it to the values they want to put into my program.  The last step is to output a stream of data in XML format that they can get.

                               

                              I see it as their program calls my program and they take the results from my program and use it in their program.  That result is just an output stream in our current java application and as they called my program, they have access to the output stream.  That only takes three lines of code in java and I just need to find out how to duplicate it in Flex.

                              • 12. Re: Serveral questions
                                rtalton Level 4

                                You may be able to use the ExternalInterface class to pass the data from the Flex app to its html wrapper page via javascript. Maybe your other program can retrieve it from that point?

                                • 13. Re: Serveral questions
                                  rtalton Level 4

                                  the only other thing I can think of is using the BrowserManager's setFragment method.

                                  • 14. Re: Serveral questions
                                    Jerry62712 Level 1

                                    Can you believe I didn't notice the misspelling in my title until now?

                                     

                                    I have no idea at all what you are talking about.  As I said I'm a newbie.  We are looking to use Flex and several of us attended a couple of day class.  This is one of the two pilot projects for Flex.  While I have extensive experience in programming (started in the mid-70s) and web design (started in the early 90s), this is new to me.

                                     

                                    I've heard that "outside" stuff needs to be done by LiveCycle or java.  We have a servlet that currently (in a java application) reads in the url query string, parses the XML formatted data, invokes our java and finally outputs to the ??? a stream of data that is formatted like XML.  That "???" is the output writer object in java.

                                     

                                    Should I just call a java servlet and if so, how?

                                    • 15. Re: Serveral questions
                                      Jerry62712 Level 1

                                      BTW, have they fixed this forum?  I got into these message responce boxes in less than a minute and not the usual hour.