List of usage examples for com.google.gwt.http.client URL encode
public static String encode(String decodedURL)
From source file:org.freemedsoftware.gwt.client.widget.LedgerWidget.java
License:Open Source License
public void loadCoverageByType(final int type, final CustomListBox lb) { if (Util.getProgramMode() == ProgramMode.JSONRPC) { // //////////////////// String[] params = { patientId, type + "" }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.PatientCoverages.GetCoverageByType", params))); try {//from www. ja va2 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 { // Window.alert("Response is:"+type+" // :"+response.getText()); covCount++; HashMap<String, String>[] result = (HashMap<String, String>[]) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]"); if (result != null) { if (result.length != 0) { hasInsurance = true; String typeName = ""; if (type == 1) typeName = _("Primary") + " "; else if (type == 2) typeName = _("Secondary") + " "; else if (type == 3) typeName = _("Tertiary") + " "; else if (type == 4) typeName = _("Work Comp") + " "; for (int i = 0; i < result.length; i++) { HashMap<String, String> m = (HashMap<String, String>) result[i]; lb.addItem(typeName + "- " + m.get("comp_name"), m.get("Id")); } } else { } if (covCount == 4 && !hasInsurance) { paymentTypeGroup.customRadioButtonGroup.get(1).setEnabled(false); paymentTypeGroup.customRadioButtonGroup.get(2).setEnabled(false); } } } catch (Exception e) { // Window.alert(e.getMessage()); } } } else { } } }); } catch (RequestException e) { Window.alert(e.toString()); } } else { } }
From source file:org.freemedsoftware.gwt.client.widget.MessageBox.java
License:Open Source License
public void showMessage(Integer messageId, MessageView messageView) { final MessageView view = messageView; if (Util.getProgramMode() == ProgramMode.STUBBED) { if (messageId == 1) { view.setText(/*from www . ja va 2 s. c o m*/ "This is some sample message according to ID#1. Here you can see that the messages can be designed using <b>HTML</b> in a <i>very cool <b>way</b></i>. <br/>You can even <sub>subcase letters</sub>."); } else if (messageId == 2) { view.setText("Text to MessageId 2"); } } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { "MessagesModule", JsonUtil.jsonify(messageId) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.api.ModuleInterface.ModuleGetRecordMethod", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { } @SuppressWarnings("unchecked") public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { HashMap<String, String> r = (HashMap<String, String>) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>"); if (r != null) { view.setText(r.get("msgtext").replace("\\", "").replace("\n", "<br/>")); view.setMsgFromId(Integer.parseInt(r.get("msgby"))); view.setMsgSubject(r.get("msgsubject")); view.setMsgPatientId(Integer.parseInt(r.get("msgpatient"))); view.setMsgBody(r.get("msgtext")); } } else { } } }); } catch (RequestException e) { } } else if (Util.getProgramMode() == ProgramMode.NORMAL) { } }
From source file:org.freemedsoftware.gwt.client.widget.MessageBox.java
License:Open Source License
public void retrieveData(String searchtag) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // Runs in STUBBED MODE => Feed with Sample Data HashMap<String, String>[] sampleData = getSampleData(); loadData(sampleData);// ww w . ja va 2 s . com } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { // Use JSON-RPC to retrieve the data String[] messagesparams = { searchtag, JsonUtil.jsonify(Boolean.FALSE) }; // TODO: get Config setting to retrieve all mail, or only new one // if (state.getUserConfig("messagebox") == "retrieveall") { // messagesparams[1] = JsonUtil.jsonify(Boolean.TRUE) ; // // } String[] countparams = { JsonUtil.jsonify(Boolean.FALSE), JsonUtil.jsonify(Boolean.FALSE) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.MessagesModule.UnreadMessages", countparams))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { GWT.log(request.toString(), ex); } public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == 200) { Integer data = (Integer) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "Integer"); if (data != null) { JsonUtil.debug("Msg count from server is:" + data); loadCounter(data); } } } }); } catch (RequestException e) { // nothing here right now } wMessages.showloading(true); // Get data RequestBuilder dataBuilder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.MessagesModule.GetAllByTag", messagesparams))); try { dataBuilder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { GWT.log(request.toString(), ex); } @SuppressWarnings("unchecked") public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == 200) { HashMap<String, String>[] data = (HashMap<String, String>[]) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]"); if (data != null) { setResult(data); loadData(data); } else wMessages.showloading(false); } } }); } catch (RequestException e) { // nothing here right now } } else if (Util.getProgramMode() == ProgramMode.NORMAL) { // Use GWT-RPC to retrieve the data // TODO: Create that stuff } }
From source file:org.freemedsoftware.gwt.client.widget.ModuleSearchWidget.java
License:Open Source License
protected void loadSuggestions(String req, final Request r, final Callback cb) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // Handle in a stubbed sort of way List<SuggestOracle.Suggestion> items = new ArrayList<SuggestOracle.Suggestion>(); map.clear();//ww w. j a v a 2s .com 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) { List<String> paramList = new ArrayList<String>(); paramList.add(req); if (selctedModuleType != null) paramList.add(selctedModuleType); String[] params = paramList.toArray(new String[0]); RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.api.ModuleSearch.picklist", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { Window.alert(ex.toString()); } @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())) { 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()) { String key = iter.next(); String val = key; //String val = (String) result.get(key); addKeyValuePair(items, val, key); } cb.onSuggestionsReady(r, new SuggestOracle.Response(items)); } } } else { Window.alert(response.toString()); } } }); } catch (RequestException e) { Window.alert(e.toString()); } } else { ModuleSearchInterfaceAsync service = null; try { service = ((ModuleSearchInterfaceAsync) Util .getProxy("org.freemedsoftware.gwt.client.ModuleSearchInterface")); } catch (Exception e) { } service.Picklist(req, new AsyncCallback<HashMap<Integer, String>>() { public void onSuccess(HashMap<Integer, String> result) { Set<Integer> keys = result.keySet(); Iterator<Integer> iter = keys.iterator(); List<SuggestOracle.Suggestion> items = new ArrayList<SuggestOracle.Suggestion>(); map.clear(); while (iter.hasNext()) { Integer keyInt = (Integer) iter.next(); String key = keyInt.toString(); // Log.debug("keyInt = " + keyInt.toString()); String val = (String) result.get(keyInt); addKeyValuePair(items, val, key); } cb.onSuggestionsReady(r, new SuggestOracle.Response(items)); } public void onFailure(Throwable t) { Window.alert(t.getMessage()); } }); } }
From source file:org.freemedsoftware.gwt.client.widget.ModuleSearchWidget.java
License:Open Source License
@Override public void getTextForValue(String val) { if (!val.equalsIgnoreCase("")) { if (Util.getProgramMode() == ProgramMode.STUBBED) { searchBox.setText("Hackenbush, Hugo Z (STUB)"); } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { textBox.setEnabled(false);//from ww w .j ava2 s. c om String[] params = { val }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.api.ModuleSearch.ToText", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { textBox.setEnabled(true); Window.alert(ex.toString()); } public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { textBox.setEnabled(true); if (Util.checkValidSessionResponse(response.getText())) { if (200 == response.getStatusCode()) { String result = (String) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "String"); if (result != null) { searchBox.setText(result); if (callback != null) { callback.jsonifiedData("done"); } } } else { Window.alert(response.toString()); } } } }); } catch (RequestException e) { textBox.setEnabled(true); Window.alert(e.toString()); } } } }
From source file:org.freemedsoftware.gwt.client.widget.MultiPageForm.java
License:Open Source License
/** * Perform RPC calls to load form based on record id. * // w ww .ja v a 2s .c om * @param form */ public void loadFormFromServer(Integer form) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // STUB } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { "XmrDefinition", JsonUtil.jsonify(form) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.api.ModuleInterface.ModuleGetRecordMethod", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Util.showErrorMsg("XmrDefinition", _("Failed to load data.")); } @SuppressWarnings("unchecked") public void onResponseReceived(Request request, Response response) { JsonUtil.debug("onResponseReceived"); if (200 == response.getStatusCode()) { JsonUtil.debug(response.getText()); HashMap<String, String> r = (HashMap<String, String>) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>"); if (r != null) { populateFormDefinition(r); } } else { Util.showErrorMsg("XmrDefinition", _("Failed to load data.")); } } }); } catch (RequestException e) { Window.alert(e.toString()); } } else { ModuleInterfaceAsync service = null; try { service = (ModuleInterfaceAsync) Util .getProxy("org.freemedsoftware.gwt.client.Api.ModuleInterface"); } catch (Exception e) { JsonUtil.debug(e.toString()); Util.showErrorMsg("XmrDefinition", _("Failed to load data.")); } service.ModuleGetRecordMethod("XmrDefinition", form, new AsyncCallback<HashMap<String, String>>() { public void onSuccess(HashMap<String, String> r) { populateFormDefinition(r); } public void onFailure(Throwable t) { Util.showErrorMsg("XmrDefinition", _("Failed to load data.")); } }); } }
From source file:org.freemedsoftware.gwt.client.widget.PatientAddresses.java
License:Open Source License
@SuppressWarnings("unchecked") public void commitChanges() { // Form map/*from w w w . jav a 2 s . co m*/ 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 {/*from w w w .j a va2 s . co 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) { 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 {/*from w ww.jav a2 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 {//from ww w. ja va2s . c om 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 } }