I have still difficulties with RPC call in a gadget. In hosted mode it works again, but not in iGoogle. Here is my Code:
package com.google.gwt.sample.cnsnews_rpc_gadget.client; import java.io.Serializable; import com.google.gwt.sample.cnsnews_rpc_gadget.client.FakeResponse; import com.google.gwt.sample.cnsnews_rpc_gadget.client.GadgetResponse; import com.google.gwt.core.client.GWT; import com.google.gwt.gadgets.client.Gadget; import com.google.gwt.gadgets.client.IntrinsicFeature; import com.google.gwt.gadgets.client.NeedsIntrinsics; import com.google.gwt.gadgets.client.Gadget.ModulePrefs; import com.google.gwt.http.client.RequestBuilder; import com.google.gwt.http.client.RequestCallback; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.ServiceDefTarget; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; @ModulePrefs(title = "CADENAS News", author = "mr") public class CADENASNews_RPC_Gadget extends Gadget<NewsPreferences> implements NeedsIntrinsics, AsyncCallback<String> { IntrinsicFeature intrinsicMethods; private final static GadgetServiceAsync gadgetService = (GadgetServiceAsync) GWT.create(GadgetService.class); static { disableStats(); } private static native void disableStats() /*-{ $wnd.$stats = null; }-*/; public void initializeFeature(IntrinsicFeature feature) { this.intrinsicMethods=feature; } public void init(NewsPreferences preferences) { ServiceDefTarget serviceDef = (ServiceDefTarget) gadgetService; String rpcUrl = serviceDef.getServiceEntryPoint(); rpcUrl = intrinsicMethods.getCachedUrl(rpcUrl); String protocol = rpcUrl.substring(0, rpcUrl.indexOf(':')); String file = rpcUrl.substring(rpcUrl.indexOf('/', rpcUrl.indexOf (':')+3)); serviceDef.setServiceEntryPoint(protocol+"://"+ getDomain() + file); RequestBuilder requestBuilder = gadgetService.getXML (CADENASNews_RPC_Gadget.this); String url = requestBuilder.getUrl(); makeGetRequest(url, requestBuilder.getRequestData(), requestBuilder.getCallback()); } private static native String getDomain() /*-{ return $wnd.document.domain; }-*/; public void onFailure(Throwable caught) { Label lbl2 = new HTML(caught.getLocalizedMessage()); RootPanel.get().add(lbl2); } public void onSuccess(String result) { Label lbl = new HTML(result); RootPanel.get().add(lbl); } private native void makeGetRequest(String url, String postdata, RequestCallback callback) /*-{ var params = {}; params[$wnd.gadgets.io.RequestParameters.METHOD] = $wnd.gadgets.io.MethodType.GET; params[$wnd.gadgets.io.RequestParameters.POST_DATA]= postdata; $wnd.gadgets.io.makeRequest(url, response, params); function response(obj) { @com.google.gwt.sample.cnsnews_rpc_gadget.client.CADENASNews_RPC_Gadget::onSuccessInternal (Lcom/google/gwt/sample/cnsnews_rpc_gadget/client/GadgetResponse;Lcom/ google/gwt/http/client/RequestCallback;)(obj, callback); }; }-*/; static void onSuccessInternal(final GadgetResponse response, RequestCallback callback) { try { String responseText = response.getText(); callback.onResponseReceived(null, new FakeResponse(response)); } catch (Exception e) { callback.onError(null, e); } } } Does anyone know what's wrong here? On 3 Dez., 15:03, flokay <f.kar...@cadenas.de> wrote: > Now if I want to make the rpc call the "onFailureMethod" is invoked > and the error message: > > "unable to initiate the asynchronous service invocation -- check the > network connection" > > What could be wrong here? > > On 1 Dez., 17:14, Eric Ayers <zun...@google.com> wrote: > > > This may be a conflict between different versions of xerces, because this > > part of the code is creating a new XML document. You should be using the > > -noredist.jar file, and expecting to resolve xerces in your GWT build. Are > > you explicitly including xerces in your build classpath? > > > It may help to checkout the gwt-gadgets project from code and build a fresh > > .jar along with the version of GWT and xerces you are using. > > > On Tue, Dec 1, 2009 at 10:37 AM, flokay <f.kar...@cadenas.de> wrote: > > > OK thanks! > > > > So I have made it with RPC now and inhostedmode, itworkswell > > > again! > > > But if I want to change it in a gadget the compiler writes the > > > following error message: > > > > Compiling module > > > com.google.gwt.sample.cnsnews_rpc_gadget.CADENASNews_RPC_Gadget > > > Computing all possible rebind results for > > > 'com.google.gwt.sample.cnsnews_rpc_gadget.client.CADENASNews_RPC_Gadget' > > > Rebinding > > > com.google.gwt.sample.cnsnews_rpc_gadget.client.CADENASNews_RPC_Gadget > > > Invoking <generate-with > > > class='com.google.gwt.gadgets.rebind.GadgetGenerator'/> > > > [ERROR] Generator > > > 'com.google.gwt.gadgets.rebind.GadgetGenerator' threw threw an > > > exception while rebinding > > > 'com.google.gwt.sample.cnsnews_rpc_gadget.client.CADENASNews_RPC_Gadget' > > > java.lang.NullPointerException > > > at > > > com.google.gwt.gadgets.rebind.GadgetGenerator.generateGadgetManifest > > > (GadgetGenerator.java:274) > > > at com.google.gwt.gadgets.rebind.GadgetGenerator.generate > > > (GadgetGenerator.java:142) > > > at com.google.gwt.dev.cfg.RuleGenerateWith.realize > > > (RuleGenerateWith.java:49) > > > at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.tryRebind > > > (StandardRebindOracle.java:113) > > > at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind > > > (StandardRebindOracle.java:62) > > > at com.google.gwt.dev.shell.StandardRebindOracle.rebind > > > (StandardRebindOracle.java:172) > > > at com.google.gwt.dev.shell.StandardRebindOracle.rebind > > > (StandardRebindOracle.java:161) > > > at com.google.gwt.dev.Precompile > > > $DistillerRebindPermutationOracle.getAllPossibleRebindAnswers > > > (Precompile.java:204) > > > at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.precompile > > > (JavaToJavaScriptCompiler.java:250) > > > at com.google.gwt.dev.Precompile.precompile(Precompile.java:300) > > > at com.google.gwt.dev.Compiler.run(Compiler.java:170) > > > at com.google.gwt.dev.Compiler$1.run(Compiler.java:124) > > > at > > > com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java: > > > 88) > > > at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger > > > (CompileTaskRunner.java:82) > > > at com.google.gwt.dev.Compiler.main(Compiler.java:131) > > > > I'm already using the gwt-gadgets-noredist.jar file! > > > Any suggestions? > > > > On 30 Nov., 17:52, Eric Ayers <zun...@google.com> wrote: > > > > See the Gadget RPC example in the gwt-google-apis project for how to > > > > set > > > > the proxy in request builder. > > > > >http://code.google.com/p/gwt-google-apis > > > > > On Mon, Nov 30, 2009 at 10:17 AM, flokay <f.kar...@cadenas.de> wrote: > > > > > Hi, > > > > > > I've got an issue with my Google Gadget: > > > > > - I'm trying to read an XML file via RequestBuilder and show it in the > > > > > gadget (only for testing purpose) > > > > > - If I try it inhostedmodewith "onModuleLoad()" method and so on, > > > > > itworkswell > > > > > - But if i add it to iGoogle the string variable of response.getText() > > > > > is empty in Firefox and in IE there appears the following message: > > > > > "...url.. is invalid or violates the same-origin security restriction" > > > > > - My XML file from which should be read is exactly in the same > > > > > directory as my gadget XML file, so there actually couldn't be a same- > > > > > origin security restriction. > > > > > > - I'm using GWT 1.7.1! > > > > > > I've tried to fix this since over a week now and I don't know what > > > > > else to do! > > > > > Could anbody help me? > > > > > > Best regards, > > > > > > flokay > > > > > > -- > > > > > > You received this message because you are subscribed to the Google > > > Groups > > > > > "Google Web Toolkit" group. > > > > > To post to this group, send email to > > > google-web-tool...@googlegroups.com. > > > > > To unsubscribe from this group, send email to > > > > > google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com> > > > <google-web-toolkit%2bunsubscr...@googlegroups.com<google-web-toolkit%252bunsubscr...@googlegroups.com> > > > > > > . > > > > > For more options, visit this group at > > > > >http://groups.google.com/group/google-web-toolkit?hl=en. > > > > > -- > > > > Eric Z. Ayers > > > > Google Web Toolkit, Atlanta, GA USA > > > > -- > > > > You received this message because you are subscribed to the Google Groups > > > "Google Web Toolkit" group. > > > To post to this group, send email to google-web-tool...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/google-web-toolkit?hl=en. > > > -- > > Eric Z. Ayers > > Google Web Toolkit, Atlanta, GA USA -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.