Hi frnds,
I have a login form in HTML which accepts few parameters and on pressing login automatically navigates to another page.
I have to make it autologin so I just set document.form.submit() and it works.
<html>
<head>
</head>
<body onLoad="document.forms['loginForm'].submit();">
<form id="loginForm" action="Login.do" method="POST">
<table>
<tr>
<td>
User ID
</td>
<td>
<input type="text" name="username" value="ABCD"/>
</td>
</tr>
<tr>
<td>
ISBN
</td>
<td>
<input type="text" name="isbn" value="11122433"/>
</td>
</tr>
<tr>
<td>
ROLE
</td>
<td>
<select name="userRole">
<option>TEACHER</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Login" />
</td>
</tr>
<table>
</form>
</body>
</html>
Now I have to incorporate the same functionality in Flex
I used HTTPService class to achieve the same in Flex without success
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" applicationComplete="useHttpService();">
<fx:Script>
<![CDATA[
import flash.net.*;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
private var service:HTTPService
public function useHttpService():void {
var parameters:Object = new Object();
parameters.username = "ABCD"
parameters.isbn = "12345"
parameters.userRole = "TEACHER"
service = new HTTPService();
service.destination = "Login.do";
service.method = "POST";
service.addEventListener("result", httpResult);
service.addEventListener("fault", httpFault);
service.send(parameters);
}
public function httpResult(event:ResultEvent):void {
var result:Object = event.result;
Alert.show(">>--- " + result.toString());
//Do something with the result.
}
public function httpFault(event:FaultEvent):void {
var faultstring:String = event.fault.faultString;
Alert.show(">>" + event.fault.toString());
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:Application>
The error message received is
>>[RPC Fault faultString="[MessagingError message='Destination 'Login.do' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']" faultCode="InvokeFailed" faultDetail="Couldn't establish a connection to 'Login.do'"]
I am not aware how to fix this error.
Any help is appreciated