2/25/2011 6:40:18 AM
Title:
Provide an example
Hey guys,
Can you provide me a sample flex application example..
It should be designed in such a way that...a simple UI will interact with java code....(Using HTTPService or your prefered way)...Finally what i want is to prepare a .war with java code and flex files and run the example from browser.
ex : build a java servlet
build UI using flex
UI should interact with JAVA servelet to get response back to browser.
Finally pack all java files and flex related files as .war file
deploy the war file in weblogic 10.3 and run the flex application from browser.
Appreciate your efforts ....if you can send me....Thank you in advance
2/25/2011 11:01:25 AM
you can post and load variables to any serverside webservide like java, php, asp using the following code.
//call this function in flex to send and load varibles
public function sendLoadData():void {
//call your webservice URL it can be ASP, PHP JAVA or anything
var request:URLRequest = new URLRequest("www.abc.com\a.php");
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
// Declare and set the value of the variables that you want to send if any
var params:Object= new Object();
params.var1= "variable1";
params.var2="variable2";
request.data = params;
request.method = URLRequestMethod.POST;
loader.addEventListener(Event.COMPLETE, loadCompleteHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
loader.load(request);
}
//Function that will receive the result of the request
private function loadCompleteHandler(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
// we are receiving two parameters here par and msg
// the webservice returns the parameters in the querystring format like this par=anything&msg=mymessage
trace("Parameter: " + loader.data.par);
trace("Message: " + loader.data.msg);
}
2/27/2011 9:17:40 AM
hey Buddy,
Thanks for your good efforts, but i need something like the mxml file should call a HTTP service (for eg: mxml file should call a servlet class which is depployed in the weblogic).
2/27/2011 9:59:31 PM
its httpservice call only. Add this script to your mxml file and call the function sendLoadData()on button click. replace the url "www.abc.com\a.php" with your servlet url .
2/28/2011 5:28:01 AM
Hey,
I have 1 strange problem, I have developed one flex application which will call servlet internally using HTTP service when button is clicked. So the data returned from the servlet will get populted to the table created in mxml.
Now here comes the issue. I compiled the mxml file, now 2 files got created .html & .swf.
When i try to run the .html file from the workspace i am able to get the table structure that is designed in mxml, but when i try to take out the two files seperately from workspace and copied to a seperate folder called TESTAPP (it is in my desktop)
When i try to run the .html file...the browser remains blank. I am not getting any thing.
I copied the swfObject.js file into TESTAPP folder and also copied the history directory to the TESTAPP folder, but still the browser remains blank when i try to run the .html file (Application is build in Flash Builer 4)
can any one try a simple example and tell me the soluton. i am dying with this problem.
Appreciate your efforts if you can provide me the solution.. Thank you in advance