hi
thanks a lot you guys
its started working
:)
On Jul 16, 10:42 am, Sean <[email protected]> wrote:
> You can simplify that a lot by just doing:
> String firstResult = result.get(0);
>
> You have a lot of conversions that are uncessceary.
>
> But judging by the error you're str has no elements in it. What you
> want to check is
> result.size() > 0
>
> On Jul 16, 10:05 am, Rahul <[email protected]> wrote:
>
> > Hi,
> > Thanks for the reply. I have changed the following things you asked me
> > to do.
>
> > This is the code of my onSuceess Method
>
> > public void onSuccess(ArrayList<String> result) {
> > // TODO
> > Auto-generated method stub
> > // String str
> > [] = (String []) result.toArray (new String
> > [result.size ()]);
> > // String h1 =
> > Integer.toString(result.get(0));
> > String str
> > [] = new String [result.size ()];
> > //copying
> > arraylist to string array
>
> > str =
> > (String[]) result.toArray (str);
> >
> > dialogBox.setText("Remote Procedure Call");
> >
> > serverResponseLabel
> >
> > .removeStyleName("serverResponseLabelError");
>
> > // I want to
> > display the first value of the array
>
> >
> > serverResponseLabel.setHTML(str[0]);
> >
> > dialogBox.center();
> >
> > closeButton.setFocus(true);
>
> > }
>
> > I am getting the following error
> > [ERROR] Uncaught exception escaped
> > java.lang.ArrayIndexOutOfBoundsException: 0
> > at com.example.test9.client.Test9$1MyHandler$1.onSuccess(Test9.java:
> > 166)
> > at com.example.test9.client.Test9$1MyHandler$1.onSuccess(Test9.java:
> > 1)
> > at
> > com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived
> > (RequestCallbackAdapter.java:215)
> > at com.google.gwt.http.client.Request.fireOnResponseReceivedImpl
> > (Request.java:264)
> > at com.google.gwt.http.client.Request.fireOnResponseReceivedAndCatch
> > (Request.java:236)
> > at com.google.gwt.http.client.Request.fireOnResponseReceived
> > (Request.java:227)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> > at java.lang.reflect.Method.invoke(Unknown Source)
> > at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:
> > 103)
> > at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod
> > (IDispatchImpl.java:126)
> > at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke
> > (IDispatchProxy.java:155)
> > at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke
> > (IDispatchImpl.java:294)
> > at com.google.gwt.dev.shell.ie.IDispatchImpl.method6
> > (IDispatchImpl.java:194)
> > at org.eclipse.swt.internal.ole.win32.COMObject.callback6
> > (COMObject.java:117)
> > at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
> > at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
> > at
> > org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
> > at com.google.gwt.dev.SwtHostedModeBase.processEvents
> > (SwtHostedModeBase.java:235)
> > at com.google.gwt.dev.HostedModeBase.pumpEventLoop
> > (HostedModeBase.java:558)
> > at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
> > at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)
>
> > i dunno how can be arrayindex out of bound, i am copying it correctly
> > i belive.
> > Thanks a lot
>
> > On Jul 16, 8:42 am, Sean <[email protected]> wrote:
>
> > > In all places you reference your callback, including the Async
> > > Interface, make it's
>
> > > AsyncCallback<ArrayList<String>> callback
>
> > > and NOT:
>
> > > AsyncCallback<<String> callback
>
> > > On Jul 15, 6:52 pm, Chad <[email protected]> wrote:
>
> > > > Well, just that. The code you originally posted showed you trying to
> > > > retrieve integer data from your result set, but your table contains
> > > > string type data so your code wouldn't have worked. Now, the error you
> > > > posted looks like you are trying to cast your result to a String in
> > > > your onSuccess method. Your result will be an ArrayList. You need to
> > > > iterate it and read each string in it.
>
> > > > HTH,
> > > > Chad
>
> > > > On Jul 15, 10:54 am, Rahul <[email protected]> wrote:
>
> > > > > Hi Sean,
> > > > > Thanks for replying.
> > > > > I understood what you are trying to say.
>
> > > > > @Chad can you elborate on "Your code would only work if the
> > > > > SourceTableName column in the
> > > > > SourceTables table is of an integer type. " My column name is
> > > > > presently an varchar type
>
> > > > > On Jul 15, 11:49 am, Rahul <[email protected]> wrote:
>
> > > > > > Hi,
> > > > > > Thanks for replying
> > > > > > I am getting the following error
>
> > > > > > [ERROR] Uncaught exception escaped
> > > > > > java.lang.ClassCastException: java.util.ArrayList cannot be cast to
> > > > > > java.lang.String
> > > > > > at
> > > > > > com.example.test7.client.Test7$1MyHandler$1.onSuccess(Test7.java:
> > > > > > 1)
> > > > > > at
> > > > > > com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceiv
> > > > > > ed
> > > > > > (RequestCallbackAdapter.java:215)
> > > > > > at
> > > > > > com.google.gwt.http.client.Request.fireOnResponseReceivedImpl
> > > > > > (Request.java:264)
> > > > > > at
> > > > > > com.google.gwt.http.client.Request.fireOnResponseReceivedAndCatch
> > > > > > (Request.java:236)
> > > > > > at com.google.gwt.http.client.Request.fireOnResponseReceived
> > > > > > (Request.java:227)
> > > > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > > > > > Method)
> > > > > > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> > > > > > Source)
> > > > > > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> > > > > > Source)
> > > > > > at java.lang.reflect.Method.invoke(Unknown Source)
> > > > > > at
> > > > > > com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:
> > > > > > 103)
> > > > > > at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod
> > > > > > (IDispatchImpl.java:126)
> > > > > > at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke
> > > > > > (IDispatchProxy.java:155)
> > > > > > at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke
> > > > > > (IDispatchImpl.java:294)
> > > > > > at com.google.gwt.dev.shell.ie.IDispatchImpl.method6
> > > > > > (IDispatchImpl.java:194)
> > > > > > at org.eclipse.swt.internal.ole.win32.COMObject.callback6
> > > > > > (COMObject.java:117)
> > > > > > at
> > > > > > org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
> > > > > > at
> > > > > > org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
> > > > > > at
> > > > > > org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
> > > > > > at com.google.gwt.dev.SwtHostedModeBase.processEvents
> > > > > > (SwtHostedModeBase.java:235)
> > > > > > at com.google.gwt.dev.HostedModeBase.pumpEventLoop
> > > > > > (HostedModeBase.java:558)
> > > > > > at
> > > > > > com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
> > > > > > at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)
>
> > > > > > any suggestions where am i going wrong ?
>
> > > > > > On Jul 15, 11:44 am, Chad <[email protected]> wrote:
>
> > > > > > > Rahul,
>
> > > > > > > Based on your query (select SourceTableName from SourceTables), I
> > > > > > > would guess that your result set would contain a single column
> > > > > > > with
> > > > > > > string data (char or varchar in SQL). If that's correct, then your
> > > > > > > loop should look more like this:
>
> > > > > > > while (rs.next()) {
> > > > > > > rowArray.add(rs.getString(1));
>
> > > > > > > }
>
> > > > > > > You can also use the column name, as in:
>
> > > > > > > while (rs.next()) {
> > > > > > > rowArray.add(rs.getString("SourceTableName"));
>
> > > > > > > }
>
> > > > > > > Your code would only work if the SourceTableName column in the
> > > > > > > SourceTables table is of an integer type.
>
> > > > > > > HTH,
> > > > > > > Chad
>
> > > > > > > On Jul 15, 9:58 am, Rahul <[email protected]> wrote:
>
> > > > > > > > Hi,
> > > > > > > > I apologize because this topic is again n again asked on the
> > > > > > > > forum,
> > > > > > > > but after reading the topics I was not able to get an answer to
> > > > > > > > my
> > > > > > > > problem.
>
> > > > > > > > I am connecting to a server and trying to display an sql query
> > > > > > > > on the
> > > > > > > > browser. Here is my server side code:
>
> > > > > > > > public class GreetingServiceImpl extends RemoteServiceServlet
> > > > > > > > implements
> > > > > > > >
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" 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/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---