kiran
unread,May 11, 2011, 9:40:12 AM5/11/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to D-Flex.org
I am trying to return values from java into flex front end using
BlazeDs.Successfully blazeds is connecting while retrieving the values
it is showing empty datagrid am not getting values from java method.
My flex code is:
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.AsyncToken;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
public function get_user():void
{
var token:AsyncToken =
ro.getOperation('getUser').send();
}
private function fault(e:FaultEvent):void
{
Alert.show("code:\n" + e.fault.faultCode + "\n
\nMessage:\n" + e.fault.faultString + "\n\nDetail:\n" +
e.fault.faultDetail);
}
private function result(e:ResultEvent):void
{
user_grid.dataProvider = e.result;
userbtn.visible = false;
lnkbtn.visible = true;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects)
here -->
<s:RemoteObject id="ro"
source="com.freelancer.GetUser"
fault="fault(event)"
destination="BlazeDsService">
<s:method name="getUser"
result="result(event)"/>
</s:RemoteObject>
</fx:Declarations>
<mx:DataGrid id="user_grid" x="-1" y="-1" width="705"
height="356">
<mx:columns>
<mx:DataGridColumn headerText="Id" dataField="id"/>
<mx:DataGridColumn headerText="Name" dataField="name"/
>
<mx:DataGridColumn headerText="Password"
dataField="pwd"/>
</mx:columns>
</mx:DataGrid>
<s:Button x="322" y="429" id="userbtn" label="Get User"
width="98"
height="23" cornerRadius="10" click="get_user()"/>
<mx:LinkButton x="331" y="429" id="lnkbtn" visible="false"
label="Connected Please Wait Loading . . ."/>
My Java Code is:
public class GetUser
{
public static void main(String[] argv)
{
System.out.println("-------- PostgreSQL " +
"JDBC Connection Testing ----------");
getUser();
}
public static List<User> getUser()
{
List<User> ls=new ArrayList<User>();
String host = "test";
String port = "1234";
String dbName = "test";
Connection connection = null;
try
{
connection = DriverManager.getConnection(
"jdbc:postgresql://" + host + ":" + port + "/" +
dbName,"user", "user");
System.out.println("Database is connected");
String strSQL = "select * from test";
Statement st = connection.createStatement();
ResultSet rs=st.executeQuery(strSQL);
System.out.println("hi,query executed");
while(rs.next())
{
User user = new User();
user.setId(rs.getInt("id"));
user.setName(rs.getString("name"));
user.setPwd(rs.getString("pwd"));
ls.add(user);
}
}
catch(Exception e)
{
System.out.println();
}
finally
{
try
{
connection.close();
}
catch (Exception ignored)
{
}
}
return ls;
}
}
Please help if if you know the solution
Thanks in Advance
Kiran