List of usage examples for com.google.gwt.http.client RequestBuilder sendRequest
public Request sendRequest(String requestData, RequestCallback callback) throws RequestException
From source file:org.freemedsoftware.gwt.client.widget.RemittBillingWidget.java
License:Open Source License
public void rebill() { if (Util.getProgramMode() == ProgramMode.JSONRPC) { // //////////////////// String[] params = { billKeysSet.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.RemittBillingTransport.rebillkeys", params))); try {/* w ww . j a va2 s . c om*/ builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { } @SuppressWarnings("unchecked") public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { if (Util.checkValidSessionResponse(response.getText())) { try { HashMap<String, String>[] result = (HashMap<String, String>[]) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]"); if (result.length > 0) { showStatus(result); } } catch (Exception e) { // Window.alert(e.getMessage()); } } } else { } } }); } catch (RequestException e) { Window.alert(e.toString()); } } else { } }
From source file:org.freemedsoftware.gwt.client.widget.RemittBillingWidget.java
License:Open Source License
public void loadStatus() { if (Util.getProgramMode() == ProgramMode.JSONRPC) { // //////////////////// String[] params = { JsonUtil.jsonify(remittUniqueIds) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.RemittBillingTransport.GetStatus", params))); try {// w w w . j a va 2 s .c o m builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { } @SuppressWarnings("unchecked") public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { if (Util.checkValidSessionResponse(response.getText())) { try { HashMap<String, String> result = (HashMap<String, String>) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "HashMap<String,String>"); if (result != null) { Iterator<String> iterator = result.keySet().iterator(); boolean isAllCompleted = true; while (iterator.hasNext() && isAllCompleted) { String id = iterator.next(); String item = result.get(id); if (!item.equals("0")) { isAllCompleted = false; } if (fileNamesMap.get(id) == null) { isAllCompleted = false; } } if (isAllCompleted) t.cancel(); for (int i = 0; i < ss.length; i++) { ss[i] = new HashMap<String, String>(); ss[i].put("billkey", billKeys[i]); ss[i].put("result", remittUniqueIds[i]); ss[i].put("target", target[i]); ss[i].put("format", formats[i]); if (result.get(remittUniqueIds[i]) != null) { if (result.get(remittUniqueIds[i]).equals("0")) { ss[i].put("status", "completed"); } else if (result.get(remittUniqueIds[i]).equals("1")) { ss[i].put("status", "validation"); } else if (result.get(remittUniqueIds[i]).equals("2")) { ss[i].put("status", "render"); } else if (result.get(remittUniqueIds[i]).equals("3")) { ss[i].put("status", "translation"); } else if (result.get(remittUniqueIds[i]).equals("4")) { ss[i].put("status", "transmission"); } else if (result.get(remittUniqueIds[i]).equals("5")) { ss[i].put("status", "unknown"); } } else ss[i].put("status", ""); } statusTable.loadData(ss); } } catch (Exception e) { // Window.alert(e.getMessage()); } } } else { } } }); } catch (RequestException e) { Window.alert(e.toString()); } } else { } }
From source file:org.freemedsoftware.gwt.client.widget.RemittBillingWidget.java
License:Open Source License
public void markAsBilled() { final RemittBillingWidget rbw = this; if (Util.getProgramMode() == ProgramMode.JSONRPC) { // //////////////////// String[] params = { JsonUtil.jsonify(billBatches) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.RemittBillingTransport.MarkAsBilled", params))); try {/*from ww w . j av a2s . co m*/ builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { } public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { if (Util.checkValidSessionResponse(response.getText())) { try { Boolean result = (Boolean) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean"); if (result != null) { if (result) { rbw.removeFromParent(); callback.jsonifiedData("update"); } } } catch (Exception e) { // Window.alert(e.getMessage()); } } } else { } } }); } catch (RequestException e) { Window.alert(e.toString()); } } else { } }
From source file:org.freemedsoftware.gwt.client.widget.RemittBillingWidget.java
License:Open Source License
public void getFileName(final String id) { // final RemittBillingWidget rbw = this; if (Util.getProgramMode() == ProgramMode.JSONRPC) { // //////////////////// String[] params = { "output", "payload", JsonUtil.jsonify(id) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.api.Remitt.GetFileList", params))); try {/*from w w w . jav a 2s.c o m*/ builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { } @SuppressWarnings("unchecked") public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { if (Util.checkValidSessionResponse(response.getText())) { try { HashMap<String, String>[] result = (HashMap<String, String>[]) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]"); if (result != null) { for (HashMap<String, String> r : result) { fileNamesMap.put(id, r.get("filename")); } } } catch (Exception e) { // Window.alert(e.getMessage()); } } } else { } } }); } catch (RequestException e) { Window.alert(e.toString()); } } else { } }
From source file:org.freemedsoftware.gwt.client.widget.ReportingWidget.java
License:Open Source License
public void populate(String reportCategory) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO: handle stubbed } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { locale, reportCategory }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.module.Reporting.GetReports", params))); try {//from ww w.java 2s .c o m builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { GWT.log("Exception", ex); } @SuppressWarnings("unchecked") public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { HashMap<String, String>[] result = (HashMap<String, String>[]) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]"); if (result != null) { reportTable.loadData(result); } else { } } else { } } }); } catch (RequestException e) { GWT.log("Exception", e); } } else { getProxy().GetReports(locale, new AsyncCallback<HashMap<String, String>[]>() { public void onSuccess(HashMap<String, String>[] r) { reportTable.loadData(r); } public void onFailure(Throwable t) { GWT.log("Exception", t); } }); } }
From source file:org.freemedsoftware.gwt.client.widget.SupportModuleListBox.java
License:Open Source License
public void loadValues() { if (Util.getProgramMode() == ProgramMode.STUBBED) { listBox.addItem("Item 1", "i1"); } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { listBox.setEnabled(false);/*from ww w . j av a2 s . c o m*/ String[] params = { moduleName, "" }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest( "org.freemedsoftware.api.ModuleInterface.ModuleSupportPicklistMethod", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { JsonUtil.debug("SupportModuleListBox: Error retrieving Data"); listBox.setEnabled(false); } @SuppressWarnings("unchecked") public void onResponseReceived(Request request, Response response) { if (Util.checkValidSessionResponse(response.getText())) { if (200 == response.getStatusCode()) { HashMap<String, String> result = (HashMap<String, String>) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>"); if (result != null) { Set<String> keys = result.keySet(); Iterator<String> iter = keys.iterator(); while (iter.hasNext()) { final String key = (String) iter.next(); final String val = (String) result.get(key); listBox.addItem(val, key); } } listBox.setEnabled(true); if (holdWidgetValue != null) setWidgetValue(holdWidgetValue); } else { Window.alert(response.toString()); } } } }); } catch (RequestException e) { listBox.setEnabled(true); JsonUtil.debug("Exception in SupportModuleListBox.loadValues; Message:" + e.getMessage()); } } }
From source file:org.freemedsoftware.gwt.client.widget.SupportModuleMultipleChoiceWidget.java
License:Open Source License
public void setValue(Integer[] values) { // In future, need to implement multiple resolve function so we don't // have to make a thousand RPC calls for a thousand entries. - Jeff // Clear current values in the widget clearValues();/*from w ww . j a va 2 s . c om*/ // Loop through all values given for (int iter = 0; iter < values.length; iter++) { if (Util.getProgramMode() == ProgramMode.STUBBED) { addValue("Value " + new Integer(iter).toString(), new Integer(iter)); } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { final Integer i = new Integer(values[iter]); String[] params = { module, JsonUtil.jsonify(i) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.api.ModuleInterface.ModuleToTextMethod", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { GWT.log("Exception", ex); } public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { String result = (String) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "String"); if (result != null) { addValue(result, i); } } else { GWT.log(response.toString(), null); } } }); } catch (RequestException e) { GWT.log("Exception", e); } } else { ModuleInterfaceAsync service = null; try { service = ((ModuleInterfaceAsync) Util .getProxy("org.freemedsoftware.gwt.client.Api.ModuleInterface")); } catch (Exception e) { } final Integer i = new Integer(values[iter]); service.ModuleToTextMethod(module, i, new AsyncCallback<String>() { public void onSuccess(String textual) { addValue(textual, i); } public void onFailure(Throwable t) { } }); } } }
From source file:org.freemedsoftware.gwt.client.widget.SupportModuleWidget.java
License:Open Source License
/** * Set value of current widget based on integer value, asynchronously. * /*from w ww .j a v a2 s .c om*/ * @param widgetValue */ public void setValue(Integer widgetValue) { value = widgetValue; if (Util.getProgramMode() == ProgramMode.STUBBED) { searchBox.setText("Stub Value"); searchBox.setTitle("Stub Value"); } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { if (widgetValue.compareTo(0) == 0) { searchBox.setText(""); searchBox.setTitle(""); } else { // textBox.setEnabled(false); String[] params = { moduleName, widgetValue.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.api.ModuleInterface.ModuleToTextMethod", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { textBox.setEnabled(true); } public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (Util.checkValidSessionResponse(response.getText())) { if (200 == response.getStatusCode()) { String result = (String) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "String"); // textBox.setEnabled(true); if (result != null) { searchBox.setText(result); searchBox.setTitle(result); if (callback != null) { callback.jsonifiedData("done"); } } } else { Window.alert(response.toString()); } } } }); } catch (RequestException e) { textBox.setEnabled(true); } } } else { ModuleInterfaceAsync service = null; try { service = ((ModuleInterfaceAsync) Util .getProxy("org.freemedsoftware.gwt.client.Api.ModuleInterface")); } catch (Exception e) { } textBox.setEnabled(false); service.ModuleToTextMethod(moduleName, widgetValue, new AsyncCallback<String>() { public void onSuccess(String textual) { textBox.setEnabled(true); searchBox.setText(textual); searchBox.setTitle(textual); } public void onFailure(Throwable t) { } }); } }
From source file:org.freemedsoftware.gwt.client.widget.SupportModuleWidget.java
License:Open Source License
protected void loadSuggestions(String req, final Request r, final Callback cb) { if (req.length() < CurrentState.getMinCharCountForSmartSearch()) return;/* w ww .j a va2s . c om*/ if (Util.getProgramMode() == ProgramMode.STUBBED) { // Handle in a stubbed sort of way List<SuggestOracle.Suggestion> items = new ArrayList<SuggestOracle.Suggestion>(); map.clear(); addKeyValuePair(items, new String("Hackenbush, Hugo Z"), new String("1")); addKeyValuePair(items, new String("Firefly, Rufus T"), new String("2")); cb.onSuggestionsReady(r, new SuggestOracle.Response(items)); } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { RequestBuilder builder = null; if (hasAdditionalParameters) { String[] params = { moduleName, req, JsonUtil.jsonify(addParameters) }; builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest( "org.freemedsoftware.api.ModuleInterface.ModuleSupportPicklistMethod", params))); } else { String[] params = { moduleName, req }; builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest( "org.freemedsoftware.api.ModuleInterface.ModuleSupportPicklistMethod", params))); } try { builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { } @SuppressWarnings("unchecked") public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (Util.checkValidSessionResponse(response.getText())) { if (200 == response.getStatusCode()) { HashMap<String, String> result = (HashMap<String, String>) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>"); if (result != null) { Set<String> keys = result.keySet(); Iterator<String> iter = keys.iterator(); List<SuggestOracle.Suggestion> items = new ArrayList<SuggestOracle.Suggestion>(); map.clear(); while (iter.hasNext()) { final String key = (String) iter.next(); final String val = (String) result.get(key); addKeyValuePair(items, val, key); } cb.onSuggestionsReady(r, new SuggestOracle.Response(items)); } else // if no result then set value to 0 setValue(0); } else { GWT.log("Result " + response.getStatusText(), null); } } } }); } catch (RequestException e) { GWT.log("Exception thrown: ", e); } } else { ModuleInterfaceAsync service = null; try { service = ((ModuleInterfaceAsync) Util .getProxy("org.freemedsoftware.gwt.client.Api.ModuleInterface")); } catch (Exception e) { } service.ModuleSupportPicklistMethod(moduleName, req, new AsyncCallback<HashMap<String, String>>() { public void onSuccess(HashMap<String, String> result) { Set<String> keys = result.keySet(); Iterator<String> iter = keys.iterator(); List<SuggestOracle.Suggestion> items = new ArrayList<SuggestOracle.Suggestion>(); map.clear(); while (iter.hasNext()) { final String key = (String) iter.next(); final String val = (String) result.get(key); addKeyValuePair(items, val, key); } cb.onSuggestionsReady(r, new SuggestOracle.Response(items)); } public void onFailure(Throwable t) { GWT.log("Exception thrown: ", t); } }); } }
From source file:org.freemedsoftware.gwt.client.widget.UserMultipleChoiceWidget.java
License:Open Source License
public void setValue(Integer[] values) { // In future, need to implement multiple resolve function so we don't // have to make a thousand RPC calls for a thousand entries. - Jeff // Clear current values in the widget clearValues();// w w w. ja va2 s. c o m // Loop through all values given for (int iter = 0; iter < values.length; iter++) { if (Util.getProgramMode() == ProgramMode.STUBBED) { addValue("Value " + new Integer(iter).toString(), new Integer(iter)); } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { final Integer i = new Integer(values[iter]); String[] params = { i.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.api.UserInterface.GetRecord", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { GWT.log("Exception", ex); } @SuppressWarnings("unchecked") public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { HashMap<String, String> result = (HashMap<String, String>) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>"); if (result != null) { addValue(result.get("userdescrip"), i); } } else { GWT.log(response.toString(), null); } } }); } catch (RequestException e) { GWT.log("Exception", e); } } else { UserInterfaceAsync service = null; try { service = ((UserInterfaceAsync) Util .getProxy("org.freemedsoftware.gwt.client.Api.UserInterface")); } catch (Exception e) { } final Integer i = new Integer(values[iter]); service.GetRecord(i, new AsyncCallback<HashMap<String, String>>() { public void onSuccess(HashMap<String, String> rec) { addValue(rec.get("userdescrip"), i); } public void onFailure(Throwable t) { } }); } } }