put a debug in the result function to see what the java is returning.

---> Akshar Kaul <---



On Wed, May 11, 2011 at 19:05, kiran <[email protected]> wrote:

> 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 blank 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 me if any one knows the solution.
>
>
>
>
>
> Thanks in Advance,
> Kiran
>
> --
> You received this message because you are subscribed to the Google Groups
> "Flex India Community" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/flex_india?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en.

Reply via email to