List of usage examples for com.google.gwt.http.client RequestBuilder GET
Method GET
To view the source code for com.google.gwt.http.client RequestBuilder GET.
Click Source Link
From source file:es.deusto.weblab.client.configuration.ConfigurationManager.java
License:Open Source License
public void start() { final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, this.configurationPath); try {/*from www .j a v a2 s. c om*/ builder.sendRequest(null, new RequestCallback() { @Override public void onError(Request request, Throwable exception) { ConfigurationManager.this.callback.onFailure(exception); } @Override public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() / 100 == 2 || response.getStatusCode() / 100 == 3) { final JSONValue value; try { value = JSONParser.parseLenient(response.getText()); } catch (final Exception e) { ConfigurationManager.this.callback.onFailure(new ConfigurationException( "Error parsing configuration: " + e.getMessage(), e)); return; } final JSONObject objValue = value.isObject(); if (objValue == null) { ConfigurationManager.this.callback.onFailure( new ConfigurationException("Error parsing configuration: object expected")); return; } for (final String key : objValue.keySet()) { final JSONValue currentValue = objValue.get(key); if (currentValue == null) { ConfigurationManager.this.callback.onFailure(new ConfigurationException( "Error parsing configuration: empty value for key: " + key)); return; } ConfigurationManager.this.configurationMap.put(key, currentValue); } ConfigurationManager.this.callback.onLoaded(); } else { ConfigurationManager.this.callback .onFailure(new ConfigurationException("Invalid status code: " + response.getStatusCode() + "; " + response.getStatusText())); } } }); } catch (final RequestException e1) { ConfigurationManager.this.callback .onFailure(new ConfigurationException("Exception thrown creating request: " + e1.getMessage())); } }
From source file:es.eucm.ead.engine.html.platform.GdxGWTAssetHandler.java
License:Open Source License
@Override public void getTextfileAsync(String path, TextHandler textHandler) { try {//from ww w .j av a2s .co m new RequestBuilder(RequestBuilder.GET, path).sendRequest("", new TextRequestCallback(textHandler)); } catch (RequestException e) { textHandler.handle(null); } }
From source file:fi.jyu.student.jatahama.onlineinquirytool.client.OnlineInquiryTool.java
License:Open Source License
/** * Check servlet existence/*from w ww. j a v a2 s . co m*/ */ private void checkServlet() throws RequestException { RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, loadsaveServletUrl); rb.setTimeoutMillis(10000); rb.setRequestData("Hello!"); rb.setCallback(this); rb.send(); }
From source file:fr.gael.dhus.gwt.client.page.SearchViewPage.java
License:Open Source License
private static void getHTML(final XMLNodeData parent, boolean loadMoreNodeClicked, final AccessDeniedRedirectionCallback<List<XMLNodeData>> callback) { String request = loadMoreNodeClicked ? parent.getLoadMoreRequest() : parent.getRequest(); String urlToRead = displayedProduct.getOdataPath(GWT.getHostPageBaseURL()) + "/" + request; urlToRead = URL.encode(urlToRead); urlToRead = urlToRead.replaceAll("#", "%23"); RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, urlToRead); try {/* w ww . j a va 2 s .c o m*/ builder.sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { Document doc = XMLParser.parse(response.getText()); ArrayList<XMLNodeData> xmlNodes = new ArrayList<XMLNodeData>(); NodeList list = doc.getFirstChild().getChildNodes(); for (int listId = 0; listId < list.getLength(); listId++) { if (list.item(listId).getNodeName() == "entry") { NodeList entryNodes = list.item(listId).getChildNodes(); Integer childrenNumber = 0; String name = null; String value = ""; String path = parent.getPath(); for (int entryNodeId = 0; entryNodeId < entryNodes.getLength(); entryNodeId++) { Node node = entryNodes.item(entryNodeId); NodeList children = node.getChildNodes(); if (node.getNodeName() == "title") { for (int childId = 0; childId < children.getLength(); childId++) { Node child = children.item(childId); if (child.getNodeName() == "#text") { name = child.getNodeValue(); } } } if (node.getNodeName() == "m:properties") { NodeList properties = node.getChildNodes(); for (int propertyId = 0; propertyId < properties.getLength(); propertyId++) { Node property = properties.item(propertyId); NodeList ns = property.getChildNodes(); if (property.getNodeName() == "d:ChildrenNumber") { for (int nId = 0; nId < ns.getLength(); nId++) { Node n = ns.item(nId); if (n.getNodeName() == "#text") { childrenNumber = new Integer(n.getNodeValue()); } } } if (property.getNodeName() == "d:Value") { for (int nId = 0; nId < ns.getLength(); nId++) { Node n = ns.item(nId); if (n.getNodeName() == "#text") { value = n.getNodeValue() == null ? "" : n.getNodeValue(); } } } } } } XMLNodeData xmlNode = new XMLNodeData(name, value, (path.isEmpty() ? "" : path + "/") + "Nodes('" + name + "')", childrenNumber); if (pathCounter.containsKey(xmlNode.getPath())) { Object item = pathCounter.get(xmlNode.getPath()); int id; if (item instanceof XMLNodeData) { XMLNodeData n = (XMLNodeData) item; n.setPath((path.isEmpty() ? "" : path + "/") + "Nodes('" + name + "[" + 1 + "]')"); id = 2; } else { id = (Integer) pathCounter.get(xmlNode.getPath()) + 1; } pathCounter.put(xmlNode.getPath(), id); xmlNode.setPath( (path.isEmpty() ? "" : path + "/") + "Nodes('" + name + "[" + id + "]')"); } else { pathCounter.put(xmlNode.getPath(), xmlNode); } xmlNode.setDeep(parent.getDeep() + 1); xmlNodes.add(xmlNode); } } callback.onSuccess(xmlNodes); } @Override public void onError(Request request, Throwable exception) { Window.alert(exception.getMessage()); } }); } catch (RequestException e) { Window.alert(e.getMessage()); return; } }
From source file:fr.mncc.gwttoolbox.ajax.client.Json.java
License:Open Source License
public static <T extends JavaScriptObject> void get(String url, String data, final AsyncCallback<T> callback) { sendRequest(RequestBuilder.GET, url, data, callback); }
From source file:fr.mncc.gwttoolbox.rpc.client.requests.RestCall.java
License:Open Source License
/** * Send a restful GET request to a given URL Does not work cross-domain * /*w ww . j a v a2 s . c om*/ * @param url * @param data * @param callback on success, returns a GWT JSON object */ public static <T extends JavaScriptObject> void retryGet(final String url, final String data, final AsyncCallback<T> callback) { sendRequest(RequestBuilder.GET, url, data, callback); }
From source file:fr.mncc.minus.ajax.client.Ajax.java
License:Open Source License
public static <T extends JavaScriptObject> void get(String url, String data, AsyncCallback<T> callback) { sendRequest(RequestBuilder.GET, url, data, callback); }
From source file:fr.putnami.pwt.doc.client.page.sample.decorator.SampleDecorator.java
License:Open Source License
private void requestFile(final String fileName) { this.sourceCode.asWidget().setVisible(false); this.sourceCode.setText(""); RequestCallback callBack = new RequestCallback() { @Override// ww w. j a v a 2s. c o m public void onResponseReceived(Request request, Response response) { if (fileName.endsWith("xml")) { SampleDecorator.this.sourceCode.setConfiguration(XmlConfiguration.XML_CONFIGURATION); } else if (fileName.endsWith("java")) { SampleDecorator.this.sourceCode.setConfiguration(JavaConfiguration.JAVA_CONFIGURATION); } else { SampleDecorator.this.displayError(new RuntimeException("Unknow file type")); } SampleDecorator.this.sourceCode.setText(response.getText()); SampleDecorator.this.sourceCode.asWidget().setVisible(true); } @Override public void onError(Request request, Throwable exception) { SampleDecorator.this.displayError(exception); } }; RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, GWT.getModuleBaseURL() + "sample/" + fileName); builder.setCallback(callBack); try { builder.send(); } catch (RequestException e) { callBack.onError(null, e); } }
From source file:fr.putnami.pwt.doc.client.page.sample.SamplePage.java
License:Open Source License
private void requestFile(final String fileName) { this.samplePageLayout.sourceCode.asWidget().setVisible(false); this.samplePageLayout.sourceCode.setText(""); RequestCallback callBack = new RequestCallback() { @Override/* w w w .ja v a 2 s . co m*/ public void onResponseReceived(Request request, Response response) { if (fileName.endsWith("xml")) { SamplePage.this.samplePageLayout.sourceCode .setConfiguration(XmlConfiguration.XML_CONFIGURATION); } else if (fileName.endsWith("java")) { SamplePage.this.samplePageLayout.sourceCode .setConfiguration(JavaConfiguration.JAVA_CONFIGURATION); } else { SamplePage.this.displayError(new RuntimeException("Unknow file type")); } SamplePage.this.samplePageLayout.sourceCode.setText(response.getText()); SamplePage.this.samplePageLayout.sourceCode.asWidget().setVisible(true); } @Override public void onError(Request request, Throwable exception) { SamplePage.this.displayError(exception); } }; RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, GWT.getModuleBaseURL() + "sample/" + fileName); builder.setCallback(callBack); try { builder.send(); } catch (RequestException e) { callBack.onError(null, e); } }
From source file:fr.putnami.pwt.doc.client.page.sample.SampleView.java
License:Open Source License
private void requestFile(final String fileName) { samplePageLayout.sourceCode.asWidget().setVisible(false); samplePageLayout.sourceCode.setText(""); RequestCallback callBack = new RequestCallback() { @Override// w w w . ja v a 2 s . c o m public void onResponseReceived(Request request, Response response) { if (fileName.endsWith("xml")) { samplePageLayout.sourceCode.setConfiguration(XmlConfiguration.XML_CONFIGURATION); } else if (fileName.endsWith("java")) { samplePageLayout.sourceCode.setConfiguration(JavaConfiguration.JAVA_CONFIGURATION); } else { displayError(new RuntimeException("Unknow file type")); } samplePageLayout.sourceCode.setText(response.getText()); samplePageLayout.sourceCode.asWidget().setVisible(true); } @Override public void onError(Request request, Throwable exception) { displayError(exception); } }; RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, GWT.getModuleBaseURL() + "sample/" + fileName); builder.setCallback(callBack); try { builder.send(); } catch (RequestException e) { callBack.onError(null, e); } }