2009 Aug 24 12:32 AM
Hi,
I am new in flex development. I'd like to transfer an XML String to Flex. Unfortunately I don't´know how to do this.
In abap web dynpro I created a string variable which contains the xml. The string contains e.g. the following hierarchical information:
In flex I created the following variable:
public var XmlString:String;
I am using a open source component in flex which can display this hierarchy. This component expects the information as a variable of type XML:
Does anyone know, how to convert the string XML into the flex XML type?
Thank you and best regards, Eddy
2009 Aug 24 5:12 AM
Hi Edger,
You can use the new XML() constructor to create an XML object from a string, as follows:
var myDataProvider:XML = new XML('<Organization name="Manager" experience="20">
<Organization name="Project Lead" experience="10">
<Organization name="Architect" experience="6"/>
<Organization name="Developer" experience="3"/>
<Organization name="Developer" experience="1"/>
<Organization name="Developer" experience="2"/>');
For more help you can refer XML type conversion in :
Regards,
Vivek
2009 Aug 24 7:19 AM
Hi Vivek,
thank you for your answer.
I knew that possibility to create an XML using your mentioned XML constructor. My problem is I originally have an xml string on abap web dynpro side.
This string is sent to flex via binding. The next step on flex side would be, to convert this string to an xml object, as you mentioned above. So there must be something like an event handler that is called, every time the xml string is changed. In this event handler the string is converted to an xml object.
Do you have an idea, how to do this?
Thank you and best regards, Eddy
2009 Aug 24 8:57 AM
Hi Edger,
Events are handled mainly on service responce or components. On change of raw value of any variable i don't find any event that you may find for any component like change of value in any TextInput etc.
When you start your application you can hit to back-end DB sytem to get latest values at present.
You can try to pass some trigger from WDA side to Flex so that it'll refresh it's XML collection at that moment.
Or another way is you have keep polling for that XML value at regular interval.
This can be done using Timer Class in Flex. you can get many examples for it's use in Help of Flex builder.
Regards,
Vivek
2009 Aug 24 10:22 AM
Hi,
I can't believe that there isn't a way to convert a string from web dynpro to an flex xml object. I heard of setter methods in flex, which are called when the WD context is changed. Would this be the right approach to handle this problem? Or has anyone else a solution?
Best Regards, Edgar
2009 Oct 23 10:02 AM
Hi Edger,
I don't know if this could help you, but you can try as you said with a setter method, like this:
public function set flexXMLString(XMLString:String):void{
var _flexXML:String = XMLString;
"your code"
}
This method will be called whenever the variable flexXMLString is changed.
Remeber to not declare flexXMLString, as it will be done implicitly but building up a setter method.
Hope this helps.
Kind reg,
R.