Flex  ResultEvent - result

Hello,
I have a WebService (Axis 1.4) at the backend and if I invoke a method of the WebService: I get the following result with (data as ResultEvent).message:
(mx.messaging.messages::AcknowledgeMessage)#0
  body = "<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body>
<loginResponse xmlns="http://controller.gui.scm.skidata.com">
<loginReturn>
<decision>grant</decision>
<message>Welcome root</message></loginReturn>
</loginResponse></soapenv:Body>
</soapenv:Envelope>"
  clientId = "DirectHTTPChannel0"
  correlationId = "5DBD5302-68F3-573D-B409-F4D79CEC2910"
  destination = ""
  headers = (Object)#1
    DSStatusCode = 200
  messageId = "1AE15396-40E2-2DCE-6AC0-F4D79D3CE748"
  timestamp = 0
  timeToLive = 0
here is my Flex method:
public function result(data:Object):void {                         
     var test:Object = (data as ResultEvent).message;  
     Alert.show("Das ist das Result beim Login: " + test);
If I thy to invoke (data as ResultEvent).result, I get "null"
My question now would be why I get null if I invoke " (data as ResultEvent).result" and what I can do in order to solve this problem.
Thanks a lot for your help,
All the best,
Generic

oK I thought I did put it under Flex... Sorry guys..

Similar Messages

  • How use PHP to read image files from a folder and display them in Flex 3 tilelist.

    Hello. I need help on displaying images from a folder dynamically using PHP and display it on FLEX 3 TileList. Im currently able to read the image files from the folder but i don't know how to display them in the TileList. This is my current code
    PHP :
    PHP Code:
    <?php
    //Open images directory
    $imglist = '';
    $dir = dir("C:\Documents and Settings\april09mpsip\My Documents\Flex Builder 3\PHPTEST\src\Assets\images");
    //List files in images directory
    while (($file = $dir->read()) !== false)
    if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
    echo "filename: " . $file . "\n";
    $dir->close();
    ?>
    FLEX 3 :
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="pic.send();">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import mx.rpc.events.FaultEvent;
    import mx.events.ItemClickEvent;
    import mx.rpc.events.ResultEvent;
    public var image:Object;
    private function resultHandler(event:ResultEvent):void
    image = (event.result);
    ta1.text = String(event.result);
    private function faultHandler(event:FaultEvent):void
    ta1.text = "Fault Response from HTTPService call:\n ";
    ]]>
    </mx:Script>
    <mx:TileList x="31" y="22" initialize="init();" dataProvider = "{image}" width="630" height="149"/>
    <mx:String id="phpPicture">http://localhost/php/Picture.php</mx:String>
    <mx:HTTPService id="pic" url="{phpPicture}" method="POST"
    result="{resultHandler(event)}" fault="{faultHandler(event)}"/>
    <mx:TextArea x="136" y="325" width="182" height="221" id="ta1" editable="false"/>
    <mx:Label x="136" y="297" text="List of files in the folder" width="182" height="20" fontWeight="bold" fontSize="13"/>
    </mx:Application>
    Thanks. Need help as soon as possbile. URGENT.

    i have made some changes, in the php part too, and following is the resulting code( i tried it, and found that it works.):
    PHP Code:
    <?php
    echo '<?xml version="1.0" encoding="utf-8"?>';
    ?>
    <root>
    <images>
    <?php
    //Open images directory
    $dir = dir("images");
    //List files in images directory
    while (($file = $dir->read()) !== false)
    if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
    echo "<image>" . $file . "</image>"; // i expect you to use the relative path in $dir, not C:\..........
    //$dir->close();
    ?>
    </images>
    </root>
    Flex Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute"
    creationComplete="callPHP();">
    <mx:Script>
    <![CDATA[
    import mx.rpc.http.HTTPService;
    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import mx.rpc.events.FaultEvent;
    import mx.events.ItemClickEvent;
    import mx.collections.ArrayCollection;
    import mx.rpc.events.ResultEvent;
    [Bindable]
    private var arr:ArrayCollection = new ArrayCollection();
    private function callPHP():void
    var hs:HTTPService = new HTTPService();
    hs.url = 'Picture.php';
    hs.addEventListener( ResultEvent.RESULT, resultHandler );
    hs.addEventListener( FaultEvent.FAULT, faultHandler )
    hs.send();
    private function resultHandler( event:ResultEvent ):void
    arr = event.result.root.images.image as ArrayCollection;
    private function faultHandler( event:FaultEvent ):void
    Alert.show( "Fault Response from HTTPService call:\n " );
    ]]>
    </mx:Script>
    <mx:TileList id="tilelist"
    dataProvider="{arr}">
    <mx:itemRenderer>
    <mx:Component>
    <mx:Image source="images/{data}" />
    </mx:Component>
    </mx:itemRenderer>
    </mx:TileList>
    </mx:Application>

  • Populate Flex Grids during view state?

    Hi, I am very new to Flex. I am working on a Flex project where I want to populate xml data in the two grids during viewstate. In my project, I have two grid which resides in the two discinct view state named as "Category" and "Topic". For these two view state, i have two disctinct grids.
    I am successfully able to populate one grid that is "Category" state grid but when i change the state on button click event another grid does not populate with the data.
    Can anyone help me with this?
    Please have a look on the code below for better idea:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="730" height="492" creationComplete="TopCategoryTopic()" currentState="HotCategory">
    <mx:states>
      <mx:State name="HotTopic">
          <mx:SetEventHandler target="{btnHotTopics}" name="click" handlerFunction="TopCategoryTopic">     
          </mx:SetEventHandler>
      <mx:SetProperty target="{btnHotTopics}" name="label" value="Top &quot;Hot&quot; Topic"/>
      <mx:RemoveChild target="{categoryGrid}"/>
      <mx:AddChild relativeTo="{canvas1}" position="lastChild">
        <mx:DataGrid id="topicGrid" x="10" y="27" width="601" height="263" color="#000000">   
        </mx:DataGrid>
      </mx:AddChild>
      <mx:AddChild relativeTo="{canvas1}" position="lastChild">
        <mx:Label x="10" y="10" text="Top &quot;Hot&quot; Topic" width="150" color="#000000" fontWeight="bold" fontFamily="Verdana" fontSize="11" id="label0"/>
      </mx:AddChild>
      </mx:State>
      <mx:State name="HotCategory">
        <mx:SetEventHandler target="{btnHotCategories}" name="click" handlerFunction="TopCategoryTopic">     
          </mx:SetEventHandler>
          <mx:SetProperty target="{btnHotCategories}" name="label" value="Top &quot;Hot&quot; Categories"/>
      <mx:RemoveChild target="{categoryGrid}"/>
      <mx:AddChild relativeTo="{canvas1}" position="lastChild">
        <mx:DataGrid id="categoryGrid"  x="10" y="27" width="601" height="263" color="#000000">   
        </mx:DataGrid>
      </mx:AddChild>
      <mx:AddChild relativeTo="{canvas1}" position="lastChild">
        <mx:Label x="10" y="10" text="Top &quot;Hot&quot; Category" width="159" color="#000000" fontWeight="bold" fontFamily="Verdana" fontSize="11" id="label2"/>
      </mx:AddChild>
      </mx:State>
    </mx:states>
    <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
      width="730" height="492" headerHeight="20"
          showCloseButton="true" borderColor="#000000"
      layout="absolute" fontSize="12" verticalScrollPolicy="off"
      horizontalScrollPolicy="off" title="Customer Success &amp; Strategy - Q4 Hot Topics/Categories"
      themeColor="#0E4463" horizontalCenter="0"
      verticalCenter="0" id="CSSTopPresenter" cornerRadius="0" alpha="1.0"
      backgroundColor="#FFFFFF" borderThickness="0" close="CloseWindow()"
      color="#FFFFFF" borderThicknessLeft="3" borderThicknessRight="3" borderThicknessBottom="3">
        <mx:Script>
            <![CDATA[
                import mx.controls.dataGridClasses.DataGridColumn;
          import mx.collections.XMLListCollection;
            import mx.managers.PopUpManager;
                import mx.rpc.events.FaultEvent;
      import mx.rpc.events.ResultEvent;
      import mx.rpc.http.HTTPService;
      import mx.events.FlexEvent;
      import mx.controls.Alert;
      import flash.events.MouseEvent;
                [Bindable]
                private var _xmlData:XMLList;
                private function TopCategoryTopic():void
                    var httpService:HTTPService = new HTTPService();
                httpService.url = "http://ri/co.UI/CtSS/Rsources/Hgory.aspx?Month=January&Year=2009";
                httpService.resultFormat = "e4x";
        httpService.addEventListener(ResultEvent.RESULT, onResultHttpService);
        httpService.send();
                //funtion to receive Http Service Response as XML Document         
              private function onResultHttpService(e:ResultEvent):void
        //var xmlData:XMLList = e.result.CategoryTopic;
        var category:XMLList = e.result.categories;
        var topic:XMLList= e.result.topics;
        if(currentState=="HotCategory")
            categoryGrid.dataProvider = category;
            for each (var node:XML in category[0].children())
                addDataGridColumn1(node.name());
        else if(currentState=="HotTopic")
          topicGrid.dataProvider = topic;
          for each (var node1:XML in topic[0].children())
            addDataGridColumn2(node1.name());
        //function to add Categories column dynamically
      private function addDataGridColumn1(dataField:String):void
        var dgc:DataGridColumn=new DataGridColumn(dataField);
        var cols:Array=categoryGrid.columns;
        cols.push(dgc);
        categoryGrid.columns=cols;
        categoryGrid.validateNow(); 
                //function to add Topic column dynamically
      private function addDataGridColumn2(dataField:String):void
        var dgc:DataGridColumn=new DataGridColumn(dataField);
        var cols:Array=topicGrid.columns;
        cols.push(dgc);
        topicGrid.columns=cols;
        topicGrid.validateNow(); 
          //funtion to remove grid window
      private function CloseWindow():void
        PopUpManager.removePopUp(this);
        ]]>
        </mx:Script>
        <mx:Button id="btnHotCategories" label="Top &quot;Hot&quot; Categories" width="173" height="37" borderColor="#2673A9" cornerRadius="6" labelPlacement="left" color="#000000" click="currentState='HotCategory'" x="45" y="23" fillAlphas="[1.0, 1.0]" fillColors="[#4D8F8D, #CCD3DE]"/>
        <mx:Button id="btnHotTopics" label="Top &quot;Hot&quot; Topic"  width="172" height="38" cornerRadius="6" borderColor="#000000"  color="#000000" click="currentState='HotTopic'"  x="46" y="78" fillAlphas="[1.0, 1.0]" fillColors="[#4D8F8D, #CCD3DE]"/>
        <mx:Canvas width="621" height="302" borderStyle="solid" borderColor="#0092F9" y="155" x="46" cornerRadius="9"  alpha="0.61" backgroundColor="#0092f9" id="canvas1">
        </mx:Canvas> 
        <mx:Image x="294" y="0" width="373" height="147" source="assets/CategoryTopic.gif"/>
    </mx:TitleWindow>
    </mx:Canvas>
    Thanks in advance.
    Vivek Jain
    Software Engineer

    I simplified the problem to it's essence and came up with this:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal"
        creationComplete="init()">
        <mx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                [Bindable]
                public var lProvider:ArrayCollection;
                private function init():void
                    var la:Array = [{label: "Conference", checked: true},
                                    {label: "Tickets", checked: false}];
                    lProvider = new ArrayCollection(la);
            ]]>
        </mx:Script>
        <mx:List id="cList" width="200" dataProvider="{lProvider}" itemClick="lProvider.refresh()">
            <mx:itemRenderer>
                <mx:Component>
                    <mx:HBox width="100%">
                        <mx:CheckBox selected="{data.checked}" click="data.checked = event.target.selected"/>
                        <mx:Label text="{data.label}"/>
                    </mx:HBox>
                </mx:Component>
            </mx:itemRenderer>
        </mx:List>
        <mx:VBox width="600">
            <mx:Panel title="Conference component" width="100%" height="200"
                    visible="{lProvider.getItemAt(0).checked}"
                    includeInLayout="{lProvider.getItemAt(0).checked}"/>
            <mx:Panel title="Ticket component" width="100%" height="200"
                    visible="{lProvider.getItemAt(1).checked}"
                    includeInLayout="{lProvider.getItemAt(1).checked}"/>
        </mx:VBox>
    </mx:Application>
    Does this help?
    Dany

  • Issues in mapping objects from java to flex - using flex4

    Hi,
    I have a class in java which i want to send to flex4 using BlazeDS as middleware. There are a few issues that i am facing and they are:
    When sending the object across (java to flex), the properties with boolean data type having value as true gets converted to properties with value as  false. Even after setting the value to true it still comes as false on flex side. Can't understand why this is happening.
    When sending the list of object containing property with boolean data type, the object on flex side does not show those properties at all. As of there were no boolean properties in that object.
    Last but not the least, When sending List<ContractFilterVO> contractFilterVOs to flex using remote call, the result typecasted to ArrayCollection does not show the holding objects as ContractFilterVOs but as plain default Object though having all the properties send, except the boolean one mentioned in above points. Basically it is not able to typecast the objects in arraycoolection but the same objects gets typecasted when sent individually.
    In all the above points i am using Remote Service through BlazeDS for connectivity with Java. I have done a lot of this stuff in Flex 3 but doing it for the first time in flex 4, is there anything that Flex 4 needs specific. Below is the pasted code for reference purpose.
    Flex Object
    package com.vo
         [RemoteClass(alias="com.vo.ContractFilterVO")]
    public class ContractFilterVO{
         public function ContractFilterVO(){
         public var contractCode:String;
         public var contractDescription:String;
         public var isIndexation:Boolean;
         public var isAdditional:Boolean;
    * Rmote Part of code
    var remoteObject:RemoteObject = new RemoteObject();
    remoteObject.destination="testService";
    remoteObject.addEventListener(ResultEvent.Result,handleResult);
    public function handleResult(event:ResultEvent):void{
         var contarctFilterVOs:ArrayCollection = event.result as ArrayCollection; //Point 2&3 probelem, if list sent form java
         var contarctFilterVO:ContractFilterVO= event.result as ContractFilterVO; //Point 1 probelem, if only single Object of type ContractFilterVO sent form java
    Java Object
    package com.vo
    public class ContractFilterVO implements Serializable 
         public function ContractFilterVO(){
         private static final long serialVersionUID = 8067201720546217193L;
         private String contractCode;
         private String contractDescription;
         private Boolean isIndexation;
         private Boolean isAdditional;
    I don't understand what is wron in my code on either side, it looks syntactically right. It would be great anyone could help me point out my mistake here. Waiting for right solutions...
    Thanks and Regards,
    Jigar

    Hi Jeffery,
    Thanks for your reply, it did solve my query @ point 3 as well as point 2 where the objects in arraycollection were not geting converted and boolean properties did not appear when list of an objects were received. And hey, i did have public functions for properties defined java class, just forgot to mention here in post, sorry for that.
    The solution you gave was right, but than what if i have a VO which has multiple List of objects coming from Java, than i would have to create an instance of each type of object on flex side this is too tedious, is'nt it? Is there any better solution... out there.
    And jeffery do you some tricks up your sleeve for this Boolean issues to that i am facing in point 1... Still struggling with this one...
    Anyone out there would be more than welcome to point my mistake, if any and provide tips/tricks or solutions...
    Thanks again to Jeffery...
    Waiting for more solutions sooner...
    thanks and Regards,
    Jigar

  • Generating PDF from Flex BarChart

    Hello,
    I am new to Flex. Have been playing with creating Advanced
    Data Grid and Bar Charts for our application prototype and would
    like to explore how to create a PDF file of the BarChart or other
    charting components.
    The requirement is simple. We show the BarChart and a button
    to view it as a PDF. When the user presses the button, the PDF
    viewing dialog should come up and the user can opt to save the PDF
    or view it (the standard way a browser deals with the PDF).
    Have read blogs, this forum and LiveCycle docs but don't
    understand clearly how Flex communicates with
    LiveCycle ES (or PDF Generator) to display the PDF. Any ideas
    or tutorials that does this would be appreciated.
    Thanks,
    Kannan

    In order to generate a PDF document, you have to call a
    method on a Java remote object that uses the XFAHelper and pass it
    some arguments.
    I modified the PDFService example in the documentation so I
    can:
    1- specify any document as opposed to hardcoding the PDF
    template name
    2- write the PDF to a file as opposed to writing it in the
    user's session
    Here is the source:
    package com.mycompany.flex.remoteObjects;
    import java.io.File;
    import java.io.IOException;
    import org.w3c.dom.Document;
    import flex.acrobat.pdf.XFAHelper;
    import flex.messaging.FlexContext;
    import flex.messaging.util.UUIDUtils;
    public class PDFService
    public PDFService()
    public Object generatePDF(Document dataset, String
    PDFdocument) throws IOException
    // Open shell PDF
    String source =
    FlexContext.getServletContext().getRealPath("/pdfgen/" +
    PDFdocument);
    int index = source.indexOf("./");
    if(index != -1 )
    // Remove the ./ added by UNIX
    source = source.substring(0, index) + source.substring(index
    + 2, source.length());
    XFAHelper helper = new XFAHelper();
    helper.open(source);
    // Import XFA dataset
    helper.importDataset(dataset);
    // Create a unique ID
    String uuid = UUIDUtils.createUUID(false);
    source =
    FlexContext.getServletContext().getRealPath("/dynamic-pdf/" + uuid
    + "_" + PDFdocument);
    index = source.indexOf("./");
    if(index != -1 )
    // Remove the ./ added by UNIX
    source = source.substring(0, index) + source.substring(index
    + 2, source.length());
    // Create the file object
    File file = new File(source);
    // Save the file
    helper.save(file);
    // Close any resources
    helper.close();
    return (uuid + "_" + PDFdocument);
    pdfgen is the folder where my PDF template resides.
    dynamic-pdf is the folder where the generated PDF are saved.
    These two folders are located under flex.war at the first
    level.
    In Flex, I wrote a Cairngorm command that calls this remote
    object and displays the generated PDF:
    package com.mycompany.core.commands
    import com.adobe.cairngorm.commands.ICommand;
    import com.adobe.cairngorm.control.CairngormEvent;
    import com.adobe.cairngorm.business.Responder;
    import
    com.mycompany.core.business.GenerateAndOpenPDFDelegate;
    import
    com.mycompany.core.control.event.GenerateAndOpenPDFEvent;
    import com.mycompany.core.model.ModelLocator;
    import flash.net.navigateToURL;
    import flash.net.URLRequest;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.events.FaultEvent;
    import mx.collections.*;
    import mx.core.Application;
    import mx.controls.Alert;
    public class GenerateAndOpenPDFCommand implements ICommand,
    Responder
    [Bindable]
    private var model:ModelLocator = ModelLocator.getInstance();
    public function GenerateAndOpenPDFCommand():void
    public function execute(event:CairngormEvent):void
    trace("Executing GenerateAndOpenPDFCommand...");
    var delegate : GenerateAndOpenPDFDelegate = new
    GenerateAndOpenPDFDelegate( this );
    var generateAndOpenPDFEvent : GenerateAndOpenPDFEvent =
    event as GenerateAndOpenPDFEvent;
    delegate.generateAndOpenPDF( generateAndOpenPDFEvent.pdfVO
    public function onResult( event : * = null ) : void
    var item:Object;
    var result:String = (event as ResultEvent).result as String;
    trace("GenerateAndOpenPDFCommand::onResult\n\n" + result);
    if (result)
    // Open the generated PDF in a new window
    navigateToURL(new URLRequest(ModelLocator.FLEX_URL +
    "dynamic-pdf/" + result), "_blank");
    // Hide the progress bar overlay
    Application.application.requestProgressBar.visible = false;
    Application.application.requestProgressBar.progressBar.source =
    null;
    Application.application.requestProgressBar.progressBar.label
    = this.model.languageDictionary["000012"];
    public function onFault( event : * = null ) : void
    // Hide the progress bar overlay
    Application.application.requestProgressBar.visible = false;
    Application.application.requestProgressBar.progressBar.source =
    null;
    // Debug
    Alert.show("GenerateAndOpenPDFCommand:\n\n" + (event as
    FaultEvent).message);
    FLEX_URL is created in this way some place else in the
    application:
    // Get the server URL from the Application's
    var server:String = Application.application.url;
    var index:uint = server.indexOf("Shell"); // Shell is the
    name of my app folder
    server = server.substring(0, index);
    // This is the flex.war/ URL
    ModelLocator.FLEX_URL = server;
    Of course, it would be better to save the PDF in the user's
    session as Adobe suggests, but I couldn't figure out how they use
    the PDFResourceServlet. First of all, I had to get its code.
    I had to decompile the java class files in the samples to get
    the source of the PDFResourceServlet as it is not in the
    documentation. Here it is:
    package com.mycompany.flex.remoteObjects;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    public class PDFResourceServlet extends HttpServlet
    public PDFResourceServlet()
    protected void doGet(HttpServletRequest req,
    HttpServletResponse res)
    throws ServletException, IOException
    doPost(req, res);
    protected void doPost(HttpServletRequest req,
    HttpServletResponse res)
    throws ServletException, IOException
    String id = req.getParameter("id");
    if(id != null)
    HttpSession session = req.getSession(true);
    try
    byte bytes[] = (byte[])(byte[])session.getAttribute(id);
    if(bytes != null)
    res.setContentType("application/pdf");
    res.setContentLength(bytes.length);
    res.getOutputStream().write(bytes);
    } else
    res.setStatus(404);
    catch(Throwable t)
    System.err.println(t.getMessage());
    private static final long serialVersionUID =
    0x7180e4383e53d335L;

  • How to save the data to sap abap using Adobe Flex

    Hi Everybody......
    I am new to Adobe flex with sap abap.
          How to save the data in sap abap using Adobe Flex coding is Action Script and using RFC web service.
    Please give me any suggisions on that.
    Thank you
    Venkatesh V

    Hi Venkatesh,
    Try with folowing coding...
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
         initialize="initApp()">
         <mx:Label x="10" y="23" text="Airline" width="90" id="lblAirline"/>
         <mx:TextInput x="108" y="21" id="txtAirline"/>
         <mx:Button x="10" y="49" label="Get Data" id="btnGetData" enabled="false" click="getData()"/>
         <mx:DataGrid x="10" y="97" id="dgFlightData" dataProvider="">
         </mx:DataGrid>
           <mx:Script>
              <![CDATA[
                   import mx.collections.ArrayCollection;
                   import mx.rpc.AbstractOperation;
                   import mx.rpc.events.FaultEvent;
                   import mx.rpc.soap.LoadEvent;
                   import mx.rpc.events.ResultEvent;
                   import mx.rpc.soap.WebService;
                   [Bindable] public var flightData:ArrayCollection;
        private var flightWS:WebService;
         private function initApp():void{
              flightWS = new WebService();
              flightWS.wsdl = "http://uscib20.wdf.sap.corp:50021/sap/bc/soap/wsdl11?services=ZGTEST&sap-client=000";
            flightWS.addEventListener(FaultEvent.FAULT,onWSError);
              flightWS.addEventListener(LoadEvent.LOAD,onWSDLLoaded);
             flightWS.addEventListener(ResultEvent.RESULT,onFlightWSGotResult);
              flightWS.loadWSDL();
    private function getData():void{
              var operation:AbstractOperation = flightWS.getOperation("ZGTEST");
              var input:Object = new Object();
              input.Airline = txtAirline.text.toUpperCase();
              operation.arguments = input;
              operation.send();
         private function onWSError  (event:FaultEvent):void{
         private function onWSDLLoaded(event:LoadEvent):void{
              btnGetData.enabled = true;
         private function onFlightWSGotResult(event:ResultEvent):void{
              flightData = event.result.SFLIGHT;
              ]]>
         </mx:Script>
    </mx:Application>
    Regards,
    Vinoth

  • Issue with setting dynamic destinations on (Flex) RemoteObject

    When setting the AMFChannel on a RemoteObject I am seeing the following behavior using builds 3.2.0.3978 and 3.0.1.1755:
    faultCode:Client.Error.DeliveryInDoubt faultString:'error' faultDetail:'Invalid URL url: 'http://mymachine:8080/myService/messagebroker/amf''
    The same client code works without incident running against 3.0.0.544.
           private function invokeGetCompoundName():void
                var remoteObj:RemoteObject = new RemoteObject();
                remoteObj.addEventListener(ResultEvent.RESULT, resultHandler);
                remoteObj.addEventListener(FaultEvent.FAULT, faultHandler);
                remoteObj.destination = "myServiceDestination";
                var channelSet:ChannelSet = new ChannelSet();
                var channel:AMFChannel = new AMFChannel("my-amf", "http://mymachine:8080/myService/messagebroker/amf");
                channel.pollingEnabled = true;
                channel.pollingInterval = 2500;
                channelSet.addChannel(channel);
                remoteObj.channelSet = channelSet;
                remoteObj.getCompoundName();   
    What I've observed is that in the more recent builds the BlazeDS server is outputting header information with mustUnderstand=true versus mustUnderstand=false when using 3.0.0.544.
    (myService does use objects with session scope)
    Version: 3
    (Header #0 name=AppendToGatewayUrl, mustUnderstand=true)
        ";jsessionid=CD046D04F6D5B4D96112319D70A511AE"
      (Message #0 targetURI=/1/onResult, responseURI=)
        (Typed Object #0 'flex.messaging.messages.AcknowledgeMessage')
          destination = null
          headers = (Object #1)
          correlationId = "588D4A0D-55E3-9EAB-395D-976720ECE4D6"
          messageId = "91A2CA0E-350B-879D-BDD6-AA2B04895C6C"
          timestamp = 1.239490699781E12
          clientId = "91A2C99B-761E-44F7-B8B3-4AA861B3148B"
          timeToLive = 0.0
          body = (Typed Object #2 'com.mypackage.CompoundName')
            objectName = "SomeObject"
            fieldName = "SomeField"
    I would appreciate any insight into this issue.  Might this be a bug, or is there something I'm doing incorrectly but getting away with in 3.0.0.544?
    Is there a way to configure the newer server versions to produce the same header output as before, if that is in fact the issue?
    Thank you,
    David

    > Leah-L Said:
    > We were able to replicate your problem here as well. We are also seeing that the destination directory for the build is determined and set *before* the pre-build VI is run. Just so I am aware, have you found any other documentation concerning Pre-Build VI's?
    Cool, thanks for confirming that I'm not crazy.   And no, I haven't found any documentation concerning this phenomenon.
    > gmart Said:
    > it potentially processes the information and so simply updating values may not have the desired effect
    Good to know. I think this should be in the documentation somewhere though, perhaps in the detailed help for the Get/Set Tag invoke nodes for a Build Spec reference.
    To fix the issue, I've just made my own "Build Executable" vi that sets the tags before the build is started. It uses the same VI that I attached earlier (confirming that the VI works). Instead of starting the build from the project window and having a pre-build vi execute, I run this stand-alone VI and it builds the app.

  • Flex 2 Compatibility?  Seeing StreamingAMFChannel compile error

    I have seen postings such as <br />http://tjordahl.blogspot.com/2008/03/blazeds-and-flex-2-compatibility.html<br />suggesting that BlazeDS is compatible with the latest versions of Flex 2 SDK.<br /><br />My experience shows that this may not be completely true.<br /><br />In Flex Builder 3, I have created a project using Flex 2.0.1 Hotfix 3 SDK.<br />This points to:<br />C:\Program Files\Adobe\Flex Builder 3\sdks\2.0.1<br />which is build 180927.<br /><br />I have code like this:<br /><br />public function sendRequest(): void {<br />        var ro:RemoteObject = new RemoteObject();<br />        ro.addEventListener(ResultEvent.RESULT, resultHandler);<br />        ro.addEventListener(FaultEvent.FAULT, faultHandler);                  <br />                  <br />             <br />     if (_channelId != null && _channelUrl != null)<br />        {<br />   var cs:ChannelSet = new ChannelSet();<br />                    <br />   var myChannel:AMFChannel = new AMFChannel(_channelId, _channelUrl);<br />   myChannel.pollingEnabled = true;<br />   myChannel.pollingInterval = 8000;<br />   cs.addChannel(myChannel);<br />   ro.channelSet = cs;<br />        }<br />               <br /><br />   ro.destination = "myService";<br />   ro.channelSet = cs;<br />                                   <br />   ro.myOperation();               <br />}<br /><br />When compiling this I get the following error message:<br /><br />Channel definition, mx.messaging.channels.StreamingAMFChannel, can not be found.<br /><br />Even when I comment out the above code referencing AMFChannel, the compile error still occurs (even when doing a "clean" build).<br /><br />Here are the relevant compiler settings:<br /><br /><?xml version="1.0" encoding="UTF-8"?><br /><actionScriptProperties mainApplicationPath="client.mxml" version="3"><br /><compiler additionalCompilerArguments="-services &quot;C:\tomcat_blazeDS\webapps\myservice\WEB-INF\flex\services-config.xml&quot;<br />  -locale en_US" copyDependentFiles="true" enableModuleDebug="true" flexSDK="Flex 2.0.1 Hotfix 3" generateAccessible="false"<br />   htmlExpressInstall="true" htmlGenerate="true" htmlHistoryManagement="true" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" <br />   outputFolderLocation="C:/tomcat_blazeDS/webapps/myservice/swf" outputFolderPath="bin-debug" sourceFolderPath="src" <br />   strict="true" useApolloConfig="false" verifyDigests="true" warn="true"><br /><compilerSourcePath/><br /><libraryPath defaultLinkType="1"><br /><libraryPathEntry kind="4" path=""><br /><modifiedEntries><br /><libraryPathEntry kind="3" linkType="4" path="${PROJECT_FRAMEWORKS}/libs/framework.swc" useDefaultLinkType="true"><br /><crossDomainRsls><br /><crossDomainRslEntry autoExtract="true" policyFileUrl="" rslUrl="framework_3.0.0.477.swz"/><br /><crossDomainRslEntry autoExtract="true" policyFileUrl="" rslUrl="framework_3.0.0.477.swf"/><br /></crossDomainRsls><br /></libraryPathEntry><br /></modifiedEntries><br /></libraryPathEntry><br /><libraryPathEntry kind="1" linkType="1" path="libs"/><br /><libraryPathEntry kind="3" linkType="1" path="myCore.swc" useDefaultLinkType="false"/><br /></libraryPath><br /><sourceAttachmentPath/><br /></compiler><br /><applications><br /><application path="client.mxml"/><br /></applications><br /><modules/><br /><buildCSSFiles/><br /></actionScriptProperties><br /><br />Any comments on whether this should work, and is supported?  If this is expected to work, I would also appreciate some ideas on work-arounds.<br /><br />Thank you,<br />David

    David,
    Even when you comment out the channel (actually all channels) that has the
    reference to mx.messaging.channels.StreamingAMFChannel this still doesn't
    work?
    Are you sure that FlexBuilder is pointing at the right services-config.xml
    file when it compiles the MXML? It can't point at a BlazeDS 'default'
    config.
    It sounds like the problem is that the Flex2 libraries in the swf are trying
    to load that channel class which is new for Flex3 and it isn't there.
    Removing any and all references to this class in the config files used to
    compile the swf should fix it.
    Let us knwo if that isn't it.
    Tom Jordahl

  • Flex bug in Validator?

    see mx.validators.Validator.as
    line:929
    ValidationResult has a constructor of :
    ValidationResult(isError:Boolean, subField:String = "",
    errorCode:String = "", errorMessage:String = "")
    The first parameter means a "ValidationResult" maybe a result
    carrying error validation result or may b]not be.
    But when the results return from function "doValidation " and
    pass to function "handleResults"(shows below),its name turns into a
    "errorResults" and make the event type to be "INVALID"
    protected function
    handleResults(errorResults:Array):ValidationResultEvent
    var resultEvent:ValidationResultEvent;
    if (errorResults.length > 0)
    resultEvent =
    new ValidationResultEvent(ValidationResultEvent.INVALID);
    resultEvent.results = errorResults;
    else
    resultEvent = new
    ValidationResultEvent(ValidationResultEvent.VALID);
    }

    It’s been reported.  Here is more information and a workaround. http://blogs.adobe.com/aharui/2011/04/catching-uncaughterror-in-flex-modules.html

  • Flex Mobile : URLLoader bytesTotal always at 0 when loading file

    Hi !
    I'm trying to load external file with UrlLoader in a Flex Mobile Project ( Initialy it was with Data/Services Options of Flash Builder, but I have the same problem ). On the complete event, it work on the desktop ( bytesTotal, xml... ), but when i install my application on my nexus one ( air version : 2.5.0.1660 ), i've no data ( bytesTotal = 0 ), but the cache of the application has grown
    The application has these autorisations :
                <uses-permission android:name="android.permission.INTERNET"/>
                <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
                <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    If someone can help me...
    Thx !
    Vince

    After messing with the URLLoader for a native windows AIR app I gave up on it. That object will return 200, ok, complete, while failing to do what it says it did.
    I never found any way to catch a real error from the server with any of the event listeners for URLLoader.  Instead I used HTTPService, it acutally returns useful data on server errors.  Here is an example, all this is tucked into my own class.
    var service:HTTPService = new HTTPService();
                   service.url = url;
                   service.resultFormat = HTTPService.RESULT_FORMAT_E4X;
                   service.method = URLRequestMethod.POST;
                   service.addEventListener(ResultEvent.RESULT,serviceResult);
                   service.addEventListener(FaultEvent.FAULT,faultResult);
                   service.send(vars);
    private function serviceResult(eResult:ResultEvent):void
                   var objResult:Object = eResult;              
                   if( objResult.result is XML )
                        xmlData = eResult.result as XML;
                        trace(xmlData);
                        dispatchEvent( new Event('eComplete') );
                   else
                        //something wrong
                        trace('BAD! No XML Returned: '+eResult.result);
                        dispatchEvent( new Event('eError') );
    private function faultResult(e:Event):void
                   if( e is ErrorEvent )
                        trace( ErrorEvent(e).text );                   
                   else if ( e is FaultEvent )
                        trace( FaultEvent(e).message.toString() );
                   else
                        trace( 'Unhandled error' );
                   dispatchEvent( new Event('eError') );

  • Using Weblogic to Deploy Simple Flex App

    Hi,
       I am trying to deploy a simple Flex application in a weblogic8.1  server , so that I can use it locally.
    Can any one please guide me where and how I have to deploy my flex app .
    I am pretty new to this can any body provide me a guide or walk through step wise for me.
    More over What is the url I need to give in the browser to access the flex app I deploy in the Weblogic server.
    (At present I am using the IIS -- just copying the .swf file and wrapper html page in to the C:\Inetpub\wwwroot and giving http://localhost/test.html
    in the browser to access it) ---  How do I do this using Weblogic 8.1
    thanks
    Nash

    Hi again Nash,
    the stuff I am doing at present is not yet permitted to be publicly available, but the principles are very straightforward. Remember that WebLogic is primarily concerned with server-side functionality and Flex with client-side, so there is not really a great deal of overlap. The place where your Flex instantiation code will sit is in one or other JSP, using code very like the templates that Adobe generate. The only thing you have to do is ensure that your JSP (or the controller/code files behind it) generate HTML that contains the necessary. I tend to use the Apache Beehive libraries for UI stuff, but from vague memory I don't think these were around in WL8 - however, it doesn't really matter what tag library you prefer as all you are doing is generating HTML that looks like the usual JavaScript calls to AC_FL_RunContent (or swfobject if you are using that method). Basically, just take the Adobe-generated template and wrap the necessary bits and pieces round the edge to make it a proper JSP.
    When you need to make calls to get functionality, just use something like
                        service = new HTTPService();
                        separator_date = new Date();
                        service.url = "get_tool_list.jsp?sep=" + separator_date.valueOf();
                        service.addEventListener(FaultEvent.FAULT , fault_handler);
                        service.addEventListener(ResultEvent.RESULT, resultHandler);
                        service.resultFormat = "text";
                        CursorManager.setBusyCursor();
                        service.requestTimeout = WEB_SERVICE_TIMEOUT;
                        service.send();
    and then inside get_tool_list.jsp (or whatever...) do the server-side functionality you need, and return the result in a suitable format that the Flex resultHandler method can then interpret and make use of.
    Hope that helps,
    Richard

  • Width of stack chart not getting retained in Flex 4 but working in Flex3

    I have a stack chart on  my dashboard when I click on stack chart it become a column chart. When I trying  to come back on stack chart by clicking on column chart the width of columns of  stack chart does not match with the previous stack  chart.
    Note: The same code is  working fine in flex 3 version.
    How can I maintain the  same width in both stack charts in flex 4 as it is performing in  flex3?
    Step 1 Monthly stack chart.
    Initially when I click on the equipment break down checkbox the stack chart appears as shown in the below screen shot.
    Step 2: Monthly chart: Then when I click on the above “Monthly stack chart”, then I resume to my original bar chart appearance as shown in the below screenshot.
    Step 3: Monthly stack chart: Further when I click on the above “Monthly chart” bar chart and move back to the “monthly stack chart” it appears as in the below screen shot in flex 4. The width of the chart in step 3 does not match with the width in step 1 of “Monthly Stack Chart”.
    Note: In flex 3 the same step 3 appears to be as shown in the below screenshot.
    How can I maintain the same width in step 1 and step 3 charts in flex 4 as it is performing in flex3?
    CODE:
    /* When click on column chart */
    private function chartDrillDown(e:ChartItemEvent):void
    {var colsr:ColumnSeries;
        If (chkEquipmentBreakdown.selected) Then
           {    loadBreakdownDataForMonth((e.hitData.chartItem.index)+1);
                         IsMonthly=true;
        Else
                DrillState=e;
                  DrillLevel= DrillLevel==0?1:0;   
                      if(DrillLevel==1)
                      {chkDEMO.selected=false;
                            LastValidatedBox.visible=false;
                          siteid = e.hitData.item.VLD_SITE_ID;
                         var obj:Object=e.hitData.item;
                colsr = ColumnSeries(e.hitData.element)
                         strassetname = obj[strTitleField].toString();
                         drillToIndex = e.hitData.item.VLD_SITE_ID;
                        viewequivalentBreakdown();
                        fromAssetToMonthly=true;
                        loadMonthlyData(siteid);
            Else
                      {     if(fromAssetToMonthly==true)
         DrillLevel=DrillLevel==1?0:1;
                          else
                            LastValidatedBox.visible=true;
                colsr = ColumnSeries(e.hitData.element)
                           siteid="-1";
                           ShowHideEquipmentBreakdown(false);
                            loadYearlyData();
                If (IsMonthly) Then
                                  onchkEquipmentBreakdownChange();
                            IsMonthly=false;
    /* Bind data To column chart */
    private function onDataLoadComplete(event:ResultEvent):void
    {                                   webServ.removeEventListener(ResultEvent.RESULT,onDataLoadComplete);                
                      var resultArr:Array = event.result.toString().split("^");
                      xmlData = new XML(resultArr[0]);
                      xmlSeries= new XML(resultArr[1]);              
                      xmlColumns=new XML(resultArr[2]);
                      if(resultArr[3]!=null)
                      {     xmlValidatedData = new XML(resultArr[3]);
                            arrSeries=createSeries(xmlSeries,xmlValidatedData);
        Else
                            arrSeries=creatSeries(xmlSeries);
                      //chart properties
                      //arrSeries=creatSeries(xmlSeries);
                      colChart.series=arrSeries;
                    arrcalc=arrSeries;
                      /*if equipment break down check box checked*/
            If (chkEquipmentBreakdown.selected) Then
                      {colChart.type="stacked";
            Else
                            colChart.type="clustered";
                      colChart.dataProvider=xmlData.Table;
                      cursorManager.removeBusyCursor();
    /* function for load the step 1 and 3 "monthly stack chart".*/
    private function onchkEquipmentBreakdownChange():void
                      colsrs.setStyle("showDataEffect", zoomOut);    
        If (chkEquipmentBreakdown.selected) Then
                      {  GHGDemo.visible=false;
                            AtmosBox.visible=false;
                            chkCompareYear.enabled=false;
                            cursorManager.setBusyCursor();
                            webServ.addEventListener(ResultEvent.RESULT, onDataLoadComplete);
                            if(strTitle==strTitle1)
                                  if(GHGGROSS.selected==true)
                                        webOper = webServ.getOperation("LoadGHGDataMonthlyBreak") as Operation;
                    webOper.send(userid,selectedYear,siteid);
                Else
                                        webOper = webServ.getOperation("LoadGHGMonthlyBreak") as Operation;
                    webOper.send(userid,selectedYear,siteid);
    /* function for load the step 2 "Monthly chart".*/
      private function loadBreakdownDataForMonth(monthnum:int):void
          {   var dayNum:uint = monthnum;
                cursorManager.setBusyCursor();
                      webServ.addEventListener(ResultEvent.RESULT, onDataLoadComplete);
                      var atmosflag:Boolean;
                      var ghggrossflag:Boolean;
                      atmosflag=false;
                      ghggrossflag=false;
                      if(strTitle==strTitle1)
                                  if(GHGGROSS.selected==true)
                                        webOper = webServ.getOperation("LoadGHGDataMonthWiseGross") as Operation;
                            webOper.send(userid,selectedYear,siteid,monthnum);
                                        ghggrossflag=true;
            Else
                                        webOper = webServ.getOperation("LoadGHGBreakDownDataMonthWiseNet") as Operation;
                           webOper.send(userid,selectedYear,siteid,monthnum);
    <mx:ColumnChart id="colChart" itemClick="chartDrillDown(event)"  dataTipFunction="dtFunc">
            <mx:horizontalAxis>
               <mx:CategoryAxis  id="catAxis"  />
                      </mx:horizontalAxis>
                <mx:verticalAxis>
                  <mx:LinearAxis id="lnrAxis" baseAtZero="true" minimum="0" title="" labelFunction="defineVerticalLabel"/>
                </mx:verticalAxis>     
                <mx:horizontalAxisRenderers>
                <mx:AxisRenderer   axis="{catAxis}" labelRotation="45">
                </mx:AxisRenderer>
          </mx:horizontalAxisRenderers>
      </mx:ColumnChart>    

    Thanks for your reply,
    I am using the Adobe flash builder 4 and the Adobe flash player 10. To upgrade from flex 3 to flex 4 I just opened the project in flex 4.I am using the default skins/themes of Adobe flash builder 4.
    But it is not working as flex 3. Please suggest some other option.
    Thanks...

  • Populate flex tree control on demand using HTTPService (Flex 3)

    First, I am sorry if the same post is already posted here but after spending 30 minutes or may be more I could not find the solution.
    By the way I have two problems. 1.) I am new to flex which I know if my own problem and soon I will handle it.
    2.) This is major problem for me. I have to populate Tree control from database and I used HTTPService to get the data from database.
    I created a object of HTTPService and on load of Tree control I am calling a function which calls the HTTP URL and returns me the first level of node for my Tree.
    When I click on any node a function is called again using HTTPService and result is appended to the currently selected node. The same goes until n level and it works fine. I was happy with my results. I am stuck in new problem. The problem is if the tree is already populated on my browser and I make some add/update/delete any node or child node, the flex doesn't make a call to HTTP URL and I am not getting updated data.
    The mxml code is below (this code has some extra things too).
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="vertical"  backgroundGradientAlphas="[1.0, 1.0]"
    backgroundGradientColors="[#000000, #868686]" >
    <mx:Script>
      <![CDATA[
       import mx.utils.StringUtil;
       import mx.rpc.http.HTTPService;
       import mx.events.ListEvent;
       import mx.binding.utils.BindingUtils;
       import mx.controls.Alert;
       import mx.rpc.events.FaultEvent;
       import mx.collections.XMLListCollection;
       import mx.utils.ObjectProxy;
       import mx.collections.ArrayCollection;
       import mx.rpc.events.ResultEvent;
       import mx.utils.ArrayUtil;
       [Bindable]
       public var datalist:XMLListCollection = new XMLListCollection();
       [Bindable]
       public var xmlFromDatabase:HTTPService=new HTTPService();
       [Bindable]
       private var xmlForChildren:HTTPService;
       private function resultHandler( event:ResultEvent ):void
           var x:XML = event.result as XML;   
           var xl:XMLList = XMLList( x );
       private function faultHandler( event:FaultEvent ):void
        Alert.show(event.message.toString());
       private function display():void
        var params:Object = {};
        params["parent"] = "0";
        xmlFromDatabase.url = "http://localhost:8080/GrailsFlex/department/tree";
        xmlFromDatabase.method = "GET";
        xmlFromDatabase.resultFormat = "e4x";
        xmlFromDatabase.useProxy = false;
        xmlFromDatabase.send(params);
        xmlFromDatabase.addEventListener(ResultEvent.RESULT,displyTree,false,0,false);
       private function displyTree(event:ResultEvent):void
        XMLtree1.dataProvider =  event.result;
        XMLtree1.labelField = "@name";
       private function getChilds(event:ListEvent):void
        try
         var xmlTree:Tree = event.currentTarget as Tree;
         var node:XML = xmlTree.selectedItem as XML
         var params:Object = {};
         params["parent"] = node.@id;
         xmlForChildren = new HTTPService();
         xmlForChildren.url = "http://localhost:8080/GrailsFlex/department/tree";
         xmlForChildren.method = "GET";
         xmlForChildren.resultFormat = "e4x";
         xmlForChildren.useProxy = false;
         xmlForChildren.send(params);
         xmlForChildren.addEventListener(ResultEvent.RESULT,appendChild,false,0,false);
         xmlForChildren.addEventListener(ListEvent.ITEM_CLICK,getChilds,false,0,false);
        catch (E:Error)
         Alert.show("getChilds Error:-- " + E.message);
       private function deleteTreeNode(xmlItem:XML):void
        var xmlParent:XML = XML(xmlItem).parent();
        if (xmlParent.@parent == null || StringUtil.trim(xmlParent.@parent) == "")
         xmlParent.@parent = "0";
        if (xmlParent.@parent != "0")
         //Recursive call until I get reach to children of root node
         deleteTreeNode(xmlParent);
        else
         // Now I am at root.
         var xmlRoot:XML = XML(xmlParent).parent();
         var bActualRoot:Boolean = false;
         if (xmlRoot == null)
          xmlRoot = xmlParent;
          bActualRoot = true;
         if (bActualRoot)
          if (xmlRoot.@parent == "0")
           try
            for each (var xl:XML in xmlParent.children())
             if (xl.@name != xmlItem.@name)
              for (var cn:int=xl.children().length()-1; cn >=0; cn--)
               delete xl.children()[cn];
           catch (ex:Error)
            Alert.show("error Real Root: " + ex.toString());
         else
          for each (var nodexm:XML in xmlRoot.children() )
           if (nodexm.@name != xmlParent.@name )
            try
             for (var cu:int=nodexm.children().length()-1; cu >=0; cu--)
              delete nodexm.children()[cu];
            catch (ex:Error)
             Alert.show("error No Real Root: " + ex.toString());
       private function appendChild(event:ResultEvent):void
        var node:XML = event.result as XML
        var sItem: XML = XMLtree1.selectedItem as XML;
        if (sItem.children().length() > 0)
         delete sItem.children();
        for(var i:int=0; i < node.children().length(); i++)
                        var item:XML = node.children()[i];
                        XMLtree1.selectedItem.appendChild(item);
                        XMLtree1.expandItem(XMLtree1.selectedItem,true,true);
        deleteTreeNode(XML(XMLtree1.selectedItem));
      ]]>
    </mx:Script>
    <mx:Tree id="XMLtree1" width="350" height="470"
          showRoot="false" creationComplete="display()" itemClick="getChilds(event)"  />
    </mx:Application>
    Thanks in advance

    Thanks buddy for the answer.
    Unfortunately the answer came after quite long time of posting the message. Anyway I was able to open a tree on demand using HttpService and due to my new requirement I changed it to RemoteObject.
    I my latest change I am able to populate tree nodes on demand and also the same solution if getting update from server via JMS using Consumer object.
    I kind a like this solution because it took me good amount of effort to find the right solution.
    If any one is intersted the he/she can reply to the post and I can provide code here or may at some location so that it can be easily downloaded.
    The solution is Flex-Grails combination.
    Thanks everybody.

  • Flex Grid Issues

    Hi,
    I am using Flex Grid in my project where i am successfully able to populate xml data dynamically. what i am doing here, I am dynamically generating the xml using httpservice. This HttpService is returning an XmlList that i am using to bind the grid dynamically.
    Here i am not fixing the column header text and column width as  in future the number of cloumns can be increased so i can't fix the column header text and column width.
    Here the issue is: how to remove " _x0020_"  from the header text and how to fix column width dynamically using Action Script.
    For better idea please refer the screen shot as attached along with post.
    Please have a look on the code as pasted below:
    <?xml version="1.0" encoding="utf-8"?><mx:Canvas 
    xmlns:mx="http://www.adobe.com/2006/mxml" width="862" height="580"><mx:TitleWindow 
    x="182" y="113" width="670" height="395" layout="vertical" title="
    Top Presenters" fontSize="12"horizontalAlign="
    center" verticalAlign="top" showCloseButton="true" close="CloseGridWindow()" verticalScrollPolicy="
    off" borderColor="#000000"horizontalScrollPolicy="
    off" borderThicknessLeft="3"borderThicknessRight="
    3" borderThicknessBottom="3" creationComplete="GetTopPresentersXMLData()" backgroundColor="
    #FFFFFF" cornerRadius="
    0" color="#FFFFFF" >
    <mx:Script><![CDATA[
    import mx.controls.dataGridClasses.DataGridColumn; 
    import mx.collections.XMLListCollection; 
    import mx.managers.PopUpManager; 
    import mx.rpc.events.FaultEvent; 
    import mx.rpc.events.ResultEvent; 
    import mx.rpc.http.HTTPService; 
    import mx.events.FlexEvent; 
    import mx.controls.Alert; 
    //funtion to get Top Presenters xml data 
    private function GetTopPresentersXMLData():void{
    var httpService:HTTPService = new HTTPService();httpService.url =
    "http://ri/CItSL/Ters.aspx?mode=all&month=march&year=2009";httpService.resultFormat =
    "e4x";httpService.addEventListener(ResultEvent.RESULT, onResultHttpService);
    httpService.send();
    Bindable] 
    private var _xmlData:XMLList; 
    //funtion to receive Http Service Response as XML Document  
    private function onResultHttpService(e:ResultEvent):void{
    var xmlData:XMLList = e.result.Table;myGrid.dataProvider = xmlData;
    for each (var node:XML in xmlData[0].children()){
    addDataGridColumn(node.name());
    //function to add column dynamically  
    private function addDataGridColumn(dataField:String):void{
    //var spacePattern:RegExp=/_x0020_/g; 
    //var andPattern:RegExp=/_x0026_/g; 
    //dataField=dataField.replace(spacePattern," "); 
    //dataField=dataField.replace(andPattern,"&"); 
    var dgc:DataGridColumn=new DataGridColumn(dataField); 
    var cols:Array=myGrid.columns;cols.push(dgc);
    myGrid.columns=cols;
    myGrid.validateNow();
    //funtion to remove grid window 
    private function CloseGridWindow():void{
    PopUpManager.removePopUp(
    this);}
    ]]>
    </mx:Script>  
    <mx:DataGrid id="myGrid" alternatingItemColors="[#A2F4EF, #EFDE7D]" x="0" y="0" sortableColumns="false" width="658" height="352" fontSize="10" verticalAlign="middle" editable="false" enabled="true" horizontalGridLineColor="#befcc4" color="#000000">  
    </mx:DataGrid>
    </mx:TitleWindow>
    Please let me know, If anyone knows the solution.

    Hi,
    You can follow the below mentioned code and see if this works for you.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
        creationComplete="onComplete();">
        <mx:Script>
            <![CDATA[
                // imports:
                import mx.events.FlexEvent;
                import mx.core.UIComponent;
                import mx.controls.dataGridClasses.DataGridColumn;
                import mx.controls.Text;
                import mx.utils.ObjectUtil;
                import mx.controls.Label;
                import mx.collections.ArrayCollection;
                // data provider:
                [Bindable] private var dp:ArrayCollection = new ArrayCollection();
                private function onComplete():void {
                    // populate data provider here
                    // to avoid calcMaxLengths execution when the app is created:
                    dp = new ArrayCollection(
                            { col1: "Short", col2: "Other column 1" },
                            { col1: "Some long string", col2: "Other column 2" },
                            { col1: "Short", col2: "Other column 3" },
                            { col1: "Short", col2: "Other column 4" },
                            { col1: "The longest value in this column", col2: "Other column 5" },
                            { col1: "Short", col2: "Other column 6" },
                            { col1: "Short", col2: "Other column 7" }
                // this is going to be executed whenever the data provider changes:
                [Bindable("dataChange")]
                private function calcMaxLengths(input:ArrayCollection):ArrayCollection {
                    // if there are items in the DP:
                    if ( input.length > 0 ) {
                        // and no SPECIAL child exists:
                        if ( getChildByName("$someTempUICToRemoveAfterFinished") == null ) {
                            // create new SPECIAL child
                            // this is required to call measureText
                            // if you use custom data grid item renderer
                            // then create instance of it instead of UIComponent:
                            var uic:UIComponent = new UIComponent();
                            // do not show and do not mess with the sizes:
                            uic.includeInLayout = false;
                            uic.visible = false;
                            // name it to leverage get getChildByName method:
                            uic.name = "$someTempUICToRemoveAfterFinished";
                            // add event listener:
                            uic.addEventListener(FlexEvent.CREATION_COMPLETE, onTempUICCreated);
                            // add to parent:
                            addChild(uic);
                    // return an input:
                    return input;
                // called when SPECIAL child is created:
                private function onTempUICCreated(event:FlexEvent):void {
                    // keep the ref to the SPECIAL child:
                    var renderer:UIComponent = UIComponent(event.target);
                    // output - this will contain max size for each column:
                    var maxLengths:Object = {};
                    // temp variables:
                    var key:String = "";
                    var i:int=0;
                    // for each item in the DP:
                    for ( i=0; i<dp.length; i++ ) {
                        var o:Object = dp.getItemAt(i);
                        // for each key in the DP row:
                        for ( key in o ) {
                            // if the output doesn't have current key yet create it and set to 0:
                            if ( !maxLengths.hasOwnProperty(key) ) {
                                maxLengths[key] = 0;
                            // check if it's simple object (may cause unexpected issues for Boolean):
                            if ( ObjectUtil.isSimple(o[key]) ) {
                                // measure the text:
                                var cellMetrics:TextLineMetrics = renderer.measureText(o[key]+"");
                                // and if the width is greater than longest found up to now:
                                if ( cellMetrics.width > maxLengths[key] ) {
                                    // set it as the longest one:
                                    maxLengths[key] = cellMetrics.width;
                    // apply column sizes:
                    for ( key in maxLengths ) {
                        for ( i=0; i<dg.columnCount; i++ ) {
                            // if the column actually exists:
                            if ( DataGridColumn(dg.columns[i]).dataField == key ) {
                                // set size + some constant margin
                                DataGridColumn(dg.columns[i]).width = Number(maxLengths[key]) + 12;
                    // cleanup:
                    removeChild(getChildByName("$someTempUICToRemoveAfterFinished"));
            ]]>
        </mx:Script>
        <mx:DataGrid id="dg" horizontalScrollPolicy="on" dataProvider="{calcMaxLengths(dp)}" width="400">
            <mx:columns>
                <mx:DataGridColumn dataField="col1" width="40" />
                <mx:DataGridColumn dataField="col2" width="100" />
            </mx:columns>
        </mx:DataGrid>
    </mx:WindowedApplication>
    Regards

  • How to get webservice result as "e4x" format in a professional solution?

    Hi. I want to get data from a .Net webservice as "e4x"
    format. It works when i use <mx notation to define the service
    in flex. However i want to build a more professional solution and
    want to implement the webservice as a class. But I can't get it to
    work such that i return the result as "e4x". Instead i get an
    object with arrays etc. The problems might be that i need to use
    the flex class operation to define "e4x" and then i need to bind
    the operation with the webservice but it seems that the webservice
    still doesn't know about to return the result as e4x. Here you see
    the code in <mx notation which is working fine:
    <mx:WebService id="WS" wsdl="
    http://localhost/testservice/service.asmx?WSDL"
    result="WS_onResult(event)" >
    <mx:operation name="HelloWorld" resultFormat="e4x" >
    <mx:request></mx:request>
    </mx:operation>
    </mx:WebService>
    And in the WS_onResult procedure i get the result by doing
    this:
    var xmlResult:XML = XML(event.result);
    As i said the above code is working fine but the code below
    doesn't work well because it doesn't return the result as "e4x":
    WS = new mx.rpc.soap.WebService();
    WS.wsdl = "
    http://localhost/testservice/service.asmx?WSDL";
    WS.addEventListener(LoadEvent.LOAD, load_listener);
    WS.addEventListener(ResultEvent.RESULT, result_listener);
    OP = new mx.rpc.soap.Operation(WS,"HelloWorld");
    WS.loadWSDL();
    And in the load procedure to perform the call:
    public function load_listener(event:LoadEvent):void {
    OP.resultFormat = "e4x";
    WS.HelloWorld.send();
    And in the result listener i get a result as object and NOT
    as "e4x". Can anyone help?
    Btw. here i add the .Net code:
    [WebMethod]
    public XmlElement HelloWorld() {
    XmlDocument doc = new XmlDocument();
    string xml = "<Test>this is a test</Test>";
    doc.LoadXml(xml);
    return doc.DocumentElement;
    }

    Hmm, try setting the resultFormat at the WS level. But what
    you have looks like it should work.
    Tracy

Maybe you are looking for