List of usage examples for com.google.gwt.http.client RequestBuilder POST
Method POST
To view the source code for com.google.gwt.http.client RequestBuilder POST.
Click Source Link
From source file:org.freemedsoftware.gwt.client.widget.PatientAddresses.java
License:Open Source License
@SuppressWarnings("unchecked") public void commitChanges() { // Form map//from ww w .jav a 2 s.c om HashMap<String, String>[] map; List<HashMap<String, String>> l = new ArrayList<HashMap<String, String>>(); Iterator<Integer> iter = addresses.keySet().iterator(); while (iter.hasNext()) { HashMap<String, String> mmp = addresses.get(iter.next()).getMap(); mmp.put("patient", patientId.toString()); if (mmp.get("id") != null) mmp.put("altered", "true"); l.add(mmp); } map = (HashMap<String, String>[]) l.toArray(new HashMap<?, ?>[0]); if (Util.getProgramMode() == ProgramMode.STUBBED) { Util.showInfoMsg("PatientAddresses", _("Updated patient addresses.")); if (onCompletion != null) { onCompletion.execute(); } } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { patientId.toString(), JsonUtil.jsonify(map) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL .encode(Util.getJsonRequest("org.freemedsoftware.module.PatientModule.SetAddresses", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { GWT.log("Exception", ex); Util.showErrorMsg("PatientAddresses", _("Failed to update patient addresses.")); } public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { Boolean result = (Boolean) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean"); if (result != null) { Util.showInfoMsg("PatientAddresses", _("Updated patient addresses.")); if (onCompletion != null) { onCompletion.execute(); } } } else { Window.alert(response.toString()); } } }); } catch (RequestException e) { GWT.log("Exception", e); Util.showErrorMsg("PatientAddresses", _("Failed to update patient addresses.")); } } else { PatientModuleAsync service = null; try { service = (PatientModuleAsync) Util.getProxy("org.freemedsoftware.gwt.client.Module.PatientModule"); } catch (Exception ex) { GWT.log("Exception", ex); } finally { service.SetAddresses(patientId, map, new AsyncCallback<Boolean>() { public void onSuccess(Boolean result) { Util.showInfoMsg("PatientAddresses", _("Updated patient addresses.")); if (onCompletion != null) { onCompletion.execute(); } } public void onFailure(Throwable t) { GWT.log("Exception", t); Util.showErrorMsg("PatientAddresses", _("Failed to update patient addresses.")); } }); } } }
From source file:org.freemedsoftware.gwt.client.widget.PatientAddresses.java
License:Open Source License
private void populate() { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO: Stubbed stuff } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { patientId.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL .encode(Util.getJsonRequest("org.freemedsoftware.module.PatientModule.GetAddresses", params))); try {// w w w .j a va 2 s.c om 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) { for (int iter = 0; iter < result.length; iter++) { // Create new address object Address a = new Address(); // Pass new address object to interface // builder a.loadData(result[iter]); addAddress(new Integer(iter + 1), a); } } } else { Window.alert(response.toString()); } } }); } catch (RequestException e) { GWT.log("Exception", e); } } else { PatientModuleAsync service = null; try { service = (PatientModuleAsync) Util.getProxy("org.freemedsoftware.gwt.client.Module.PatientModule"); } catch (Exception ex) { GWT.log("Exception", ex); } finally { service.GetAddresses(patientId, new AsyncCallback<HashMap<String, String>[]>() { public void onSuccess(HashMap<String, String>[] result) { for (int iter = 0; iter < result.length; iter++) { // Create new address object Address a = new Address(); a.setLine1(result[iter].get("line1")); a.setLine2(result[iter].get("line2")); // a.setCsz(result[iter].get("csz")); a.setCity(result[iter].get("city")); a.setStpr(result[iter].get("stpr")); a.setPostal(result[iter].get("postal")); a.setCountry(result[iter].get("country")); a.setRelation(result[iter].get("relation")); a.setType(result[iter].get("type")); // Pass new address object to interface // builder addAddress(new Integer(iter + 1), a); } } public void onFailure(Throwable t) { GWT.log("Exception", t); } }); } } }
From source file:org.freemedsoftware.gwt.client.widget.PatientAddresses.java
License:Open Source License
public void deleteAddress() { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO stubbed mode goes here } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { patientId.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.PatientModule.DeleteAddresses", params))); try {/* www. j ava 2 s.c o m*/ builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Window.alert(ex.toString()); } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { } } }); } catch (RequestException e) { Window.alert(e.getMessage()); } } else { // TODO normal mode code goes here } }
From source file:org.freemedsoftware.gwt.client.widget.PatientAddresses.java
License:Open Source License
public void deleteAddress(Address a) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO stubbed mode goes here } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { a.getAddressId().toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.PatientModule.DeleteAddressById", params))); try {/* www . jav a 2s .c o m*/ builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Window.alert(ex.toString()); } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { } } }); } catch (RequestException e) { Window.alert(e.getMessage()); } } else { // TODO normal mode code goes here } }
From source file:org.freemedsoftware.gwt.client.widget.PatientAuthorizations.java
License:Open Source License
public void commitChanges() { // Form map/*from w w w. ja va 2 s .c o m*/ // HashMap<String, String>[] map; Iterator<Integer> iter = authorizations.keySet().iterator(); while (iter.hasNext()) { HashMap<String, String> mmp = authorizations.get(iter.next()).getMap(); mmp.put("authpatient", patientId.toString()); String url = "org.freemedsoftware.module.Authorizations.Add"; if (mmp.get("id") != null) url = "org.freemedsoftware.module.Authorizations.Mod"; if (Util.getProgramMode() == ProgramMode.STUBBED) { Util.showInfoMsg("PatientAuthorization", _("Updated patient authorizations.")); if (onCompletion != null) { onCompletion.execute(); } } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { JsonUtil.jsonify(mmp) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest(url, params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { GWT.log("Exception", ex); Util.showErrorMsg("PatientAuthorization", _("Failed to update patient authorizations.")); } public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { Boolean result = (Boolean) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean"); if (result != null) { Util.showInfoMsg("PatientAuthorization", _("Updated patient authorizations.")); if (onCompletion != null) { onCompletion.execute(); } } } else { Window.alert(response.toString()); } } }); } catch (RequestException e) { GWT.log("Exception", e); Util.showErrorMsg("PatientAuthorization", _("Failed to update patient authorizations.")); } } } }
From source file:org.freemedsoftware.gwt.client.widget.PatientAuthorizations.java
License:Open Source License
private void populate() { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO: Stubbed stuff } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { patientId.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.Authorizations.GetAllAuthorizations", params))); try {//from w ww . j av a 2 s . c om 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) { for (int iter = 0; iter < result.length; iter++) { // Create new Authorization object Authorization x = new Authorization(); /* * x.setAuthorizationId(Integer.parseInt(result * [iter].get("id"))); * x.setStartingDate(result * [iter].get("authdtbegin")); * x.setEndingDate * (result[iter].get("authdtend")); * x.setAuthorizationNumber * (result[iter].get("authnum")); * x.setAuthorizationType * (result[iter].get("authtype")); * if(result[iter].get("authprov")!=null) * x.setAuthorizingProvider * (Integer.parseInt( * result[iter].get("authprov"))); * x.setProviderIdentifier * (result[iter].get("authprovid")); * if(result[iter].get("authinsco")!=null) * x.setAuthorizingInsuranceCompany(Integer. * parseInt(result[iter].get("authinsco"))); * x.setNumberofVisits(result[iter].get( * "authvisits")); * x.setUsedVisits(result[iter * ].get("authvisitsused")); * x.setComment(result * [iter].get("authcomment")); */ x.loadData(result[iter]); // builder addAuthorization(new Integer(iter + 1), x); } } } else { Window.alert(response.toString()); } } }); } catch (RequestException e) { GWT.log("Exception", e); } } }
From source file:org.freemedsoftware.gwt.client.widget.PatientAuthorizations.java
License:Open Source License
public void deleteAuthorization(Integer cid) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO stubbed mode goes here } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { cid.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.module.Authorizations.del", params))); try {// w w w .ja va2 s . c o m builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Window.alert(ex.toString()); } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { } } }); } catch (RequestException e) { Window.alert(e.getMessage()); } } else { // TODO normal mode code goes here } }
From source file:org.freemedsoftware.gwt.client.widget.PatientCoverages.java
License:Open Source License
public void commitChanges() { // Form map/*from w w w. ja v a 2 s . com*/ // HashMap<String, String>[] map; Iterator<Integer> iter = coverages.keySet().iterator(); while (iter.hasNext()) { HashMap<String, String> mmp = coverages.get(iter.next()).getMap(); Iterator<String> innerItr = mmp.keySet().iterator(); while (innerItr.hasNext()) { String key = innerItr.next(); if (mmp.get(key) == null) mmp.remove(key); } mmp.put("covpatient", patientId.toString()); String url = "org.freemedsoftware.module.PatientCoverages.Add"; if (mmp.get("id") != null) url = "org.freemedsoftware.module.PatientCoverages.Mod"; if (Util.getProgramMode() == ProgramMode.STUBBED) { Util.showInfoMsg("PatientCoverages", "Updated patient Coverages."); if (onCompletion != null) { onCompletion.execute(); } } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { JsonUtil.jsonify(mmp) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest(url, params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { GWT.log("Exception", ex); Util.showErrorMsg("PatientCoverages", _("Failed to update patient coverages.")); } public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { Boolean result = (Boolean) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean"); if (result != null) { Util.showInfoMsg("PatientCoverages", _("Updated patient coverages.")); if (onCompletion != null) { onCompletion.execute(); } } } else { Window.alert(response.toString()); } } }); } catch (RequestException e) { GWT.log("Exception", e); Util.showErrorMsg("PatientCoverages", _("Failed to update patient coverages.")); } } } }
From source file:org.freemedsoftware.gwt.client.widget.PatientCoverages.java
License:Open Source License
private void populate() { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO: Stubbed stuff } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { patientId.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.PatientCoverages.GetAllCoverages", params))); try {/*from w ww . j av a2 s .c om*/ 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) { for (int iter = 0; iter < result.length; iter++) { // Create new Coverage object Coverage x = new Coverage(); x.loadData(result[iter]); // builder addCoverage(new Integer(iter + 1), x); } } } else { Window.alert(response.toString()); } } }); } catch (RequestException e) { GWT.log("Exception", e); } } }
From source file:org.freemedsoftware.gwt.client.widget.PatientCoverages.java
License:Open Source License
public void deleteCoverage(Integer cid) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO stubbed mode goes here } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { cid.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.module.PatientCoverages.del", params))); try {//ww w .ja v a 2 s. c o m builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Window.alert(ex.toString()); } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { } } }); } catch (RequestException e) { Window.alert(e.getMessage()); } } else { // TODO normal mode code goes here } }