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.PatientEntryScreenInterface.java
License:Open Source License
/** * Internal method to load stock data into form. *//* w w w . j a va 2 s. c o m*/ protected void loadData() { if (Util.getProgramMode() == ProgramMode.STUBBED) { // STUB } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { getModuleName(), internalId.toString() }; 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(getModuleName(), "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) { populateData(r); } } else { Util.showErrorMsg(getModuleName(), "Failed to load data."); } } }); } catch (RequestException e) { Window.alert(e.toString()); } } else { ModuleInterfaceAsync service = getProxy(); service.ModuleGetRecordMethod(getModuleName(), internalId, new AsyncCallback<HashMap<String, String>>() { public void onSuccess(HashMap<String, String> r) { populateData(r); } public void onFailure(Throwable t) { Util.showErrorMsg(getModuleName(), "Failed to load data."); } }); } }
From source file:org.freemedsoftware.gwt.client.screen.AccountsReceivableScreen.java
License:Open Source License
@SuppressWarnings("unchecked") protected void refreshSearch() { if (validateForm()) {//validate form first sortableTable.clearData();//w ww . j av a 2 s.com if (Util.getProgramMode() == ProgramMode.STUBBED) { HashMap<String, String> a = new HashMap<String, String>(); a.put("item_type", "item type1"); a.put("item", "item 1"); a.put("patient", "abc"); a.put("provider", "JEFF"); a.put("date_of", "1979-08-10"); a.put("total_balance", "28"); a.put("payment_date", "1979-09-10"); a.put("procedure_id", "22"); a.put("money_out", "200"); a.put("money_in", "500"); a.put("id", "1"); List<HashMap<String, String>> l = new ArrayList<HashMap<String, String>>(); l.add(a); sortableTable.loadData((HashMap<String, String>[]) l.toArray(new HashMap<?, ?>[0])); } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { HashMap<String, String> criteria = populateCreteria(); String[] params = { JsonUtil.jsonify(criteria) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.api.Ledger.AgingReportQualified", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Window.alert(ex.toString()); } 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.length > 0) { sortableTableEmptyLabel.setVisible(false); } else { sortableTableEmptyLabel.setVisible(true); Util.showErrorMsg(getClass().getName(), _("No record found!")); } sortableTable.loadData(result); } else { Window.alert(response.toString()); sortableTableEmptyLabel.setVisible(true); } } } }); } catch (RequestException e) { Window.alert(e.toString()); sortableTableEmptyLabel.setVisible(true); } } else { // TODO normal mode code goes here } } }
From source file:org.freemedsoftware.gwt.client.screen.ACLScreen.java
License:Open Source License
public void onClick(ClickEvent evt) { Widget w = (Widget) evt.getSource(); if (w == addGroupButton) { if (checkInput() == true) { blockScreenWidget.setText(_("Please wait while permissions are being applied...")); aclContainerVPanel.add(blockScreenWidget); HashMap<String, String> m = new HashMap<String, String>(); m.put("groupName", groupName.getText()); String requestURL = "org.freemedsoftware.module.ACL.AddGroupWithPermissions"; if (groupId != null) { requestURL = "org.freemedsoftware.module.ACL.ModGroupWithPermissions"; m.put("groupId", groupId.toString()); }//from www . j ava 2 s . c o m final HashMap<String, List> permissions = new HashMap<String, List>(); final HashMap<String, List> allPermiHashMap = populateAllPermissions(); final Iterator<String> aclPermissionsMapItr = allPermiHashMap.keySet().iterator(); int permissionAddedCounter = 0; while (aclPermissionsMapItr.hasNext()) { String section = aclPermissionsMapItr.next(); permissions.put(section, allPermiHashMap.get(section)); permissionAddedCounter++; if (permissionAddedCounter == 8) { if (allPermiHashMap.get("admin") != null) permissions.put("admin", allPermiHashMap.get("admin")); if (allPermiHashMap.get("acl") != null) permissions.put("acl", allPermiHashMap.get("acl")); break; } } if (permissions.size() == 0) { Window.alert(_("Please select at least one module!")); aclContainerVPanel.remove(blockScreenWidget); return; } if (Util.getProgramMode() == ProgramMode.STUBBED) { // Do nothing. } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { JsonUtil.jsonify(m), JsonUtil.jsonify(permissions) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest(requestURL, params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Util.showErrorMsg("ACL", _("Failed to add.")); } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { Integer r = (Integer) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "Integer"); if (r != null) { if (aclPermissionsMapItr.hasNext()) sendDataInChucks(aclPermissionsMapItr, allPermiHashMap, r);//Sending data to server in chunks else { aclContainerVPanel.remove(blockScreenWidget); retrieveAllGroups(); clearForm(); Util.showInfoMsg(className, _("Permissions successfully applied.")); } } else { Boolean b = (Boolean) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "Boolean"); if (b) { if (aclPermissionsMapItr.hasNext()) sendDataInChucks(aclPermissionsMapItr, allPermiHashMap, groupId);//Sending data to server in chunks else { aclContainerVPanel.remove(blockScreenWidget); retrieveAllGroups(); clearForm(); Util.showInfoMsg(className, _("Permissions successfully applied.")); } } } } else { Util.showErrorMsg("ACL", _("Failed to apply permissions.")); } } }); } catch (RequestException e) { Util.showErrorMsg("Bottle Transfer", "Failed to apply Permissions."); } } else { // TODO: Create GWT-RPC stuff here } } } else if (w == deleteGroupButton) { if (true) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // Do nothing. } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { JsonUtil.jsonify(groupId) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.ACL.DelGroupWithPermissions", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Util.showErrorMsg("ACL", _("Failed to delete.")); } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { Boolean flag = (Boolean) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean"); if (flag) { Util.showInfoMsg(className, _("Successfully deleted.")); retrieveAllGroups(); clearForm(); } } else { Util.showErrorMsg("ACL", _("Failed to add.")); } } }); } catch (RequestException e) { Util.showErrorMsg("ACL", _("Failed to add.")); } } else { // TODO: Create GWT-RPC stuff here } } } else if (w == clearButton) { clearForm(); } else if (w == copyButton) { copyGroup(); } }
From source file:org.freemedsoftware.gwt.client.screen.ACLScreen.java
License:Open Source License
public void retrieveAllGroups() { if (Util.getProgramMode() == ProgramMode.STUBBED) { // Do nothing } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { // Use JSON-RPC to retrieve the data String[] params = { JsonUtil.jsonify(true) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.module.ACL.userGroups", params))); try {//ww w .j av a2 s . com builder.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) { groupsTable.clearData(); groupsTable.loadData(data); } } } }); } 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.screen.ACLScreen.java
License:Open Source License
public void getACLPermissions() { if (Util.getProgramMode() == ProgramMode.STUBBED) { // Do nothing } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { // Use JSON-RPC to retrieve the data String[] params = {};/* ww w . j a v a 2s . c om*/ RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.module.ACL.GetAllPermissions", params))); try { builder.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) { addACLGroupPermissions(data); blockScreenWidget.removeFromParent(); } } } }); } 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.screen.ACLScreen.java
License:Open Source License
public void getGroupPermissions(Integer groupId) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // Do nothing } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { // Use JSON-RPC to retrieve the data String[] params = { JsonUtil.jsonify(groupId) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.module.ACL.GetGroupPermissions", params))); try {//from ww w . j a v a 2 s. c om builder.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) { Iterator<String> iterator = data.keySet().iterator(); while (iterator.hasNext()) { final String section = iterator.next(); String[] values = data.get(section); for (int i = 0; i < values.length; i++) { final String value = values[i]; if (aclPermissionsMap.get(section + ":" + value) != null) aclPermissionsMap.get(section + ":" + value).setValue(true); } } addGroupButton.setText(_("Modify Group")); deleteGroupButton.setVisible(true); copyButton.setVisible(true); } } } }); } 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.screen.CallInScreen.java
License:Open Source License
public void showCallinInfo(Integer callinId) { tabPanel.selectTab(0);/*from www . j a v a 2 s. c o m*/ if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO STUBBED MODE STUFF } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { JsonUtil.jsonify(callinId) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.module.Callin.GetDetailedRecord", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { } @SuppressWarnings("unchecked") public void onResponseReceived(Request request, Response response) { if (Util.checkValidSessionResponse(response.getText())) { if (200 == response.getStatusCode()) { HashMap<String, String> data = (HashMap<String, String>) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>"); if (data != null) { Popup callinDetailPopup = new Popup(); callinDetailPopup.setPixelSize(500, 20); FlexTable callinPatientDetail = new FlexTable(); while (callinPatientDetail.getRowCount() > 0) callinPatientDetail.removeRow(0); int row = 0; callinPatientDetail.setWidget(row, 0, new Label(_("Name") + ":")); callinPatientDetail.setWidget(row++, 1, new Label(data.get("name"))); callinPatientDetail.setWidget(row, 0, new Label(_("Date of Birth") + ":")); callinPatientDetail.setWidget(row++, 1, new Label(data.get("dob"))); callinPatientDetail.setWidget(row, 0, new Label(_("Complaint") + ":")); callinPatientDetail.setWidget(row++, 1, new Label(data.get("complaint"))); callinPatientDetail.setWidget(row, 0, new Label(_("Home Phone") + ":")); callinPatientDetail.setWidget(row++, 1, new Label(data.get("phone_home"))); callinPatientDetail.setWidget(row, 0, new Label(_("Work Phone") + ":")); callinPatientDetail.setWidget(row++, 1, new Label(data.get("phone_work"))); callinPatientDetail.setWidget(row, 0, new Label(_("Facility") + ":")); callinPatientDetail.setWidget(row++, 1, new Label(data.get("facility"))); callinPatientDetail.setWidget(row, 0, new Label(_("Provider") + ":")); callinPatientDetail.setWidget(row++, 1, new Label(data.get("physician"))); callinPatientDetail.setWidget(row, 0, new Label(_("Call Date") + ":")); callinPatientDetail.setWidget(row++, 1, new Label(data.get("call_date"))); callinPatientDetail.setWidget(row, 0, new Label(_("Took Call") + ":")); callinPatientDetail.setWidget(row++, 1, new Label(data.get("took_call"))); PopupView viewInfo = new PopupView(callinPatientDetail); callinDetailPopup.setNewWidget(viewInfo); callinDetailPopup.initialize(); } } else { } } } }); } catch (RequestException e) { } } else { // TODO NORMAL MODE STUFF } }
From source file:org.freemedsoftware.gwt.client.screen.CallInScreen.java
License:Open Source License
protected void modifyEntry(final Integer callinId) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO STUBBED MODE STUFF } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { JsonUtil.jsonify(callinId) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.Callin.GetDetailedRecordWithIntake", params))); try {//from www .j a v a2 s .c o m builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { } @SuppressWarnings("unchecked") public void onResponseReceived(Request request, Response response) { if (Util.checkValidSessionResponse(response.getText())) { if (200 == response.getStatusCode()) { HashMap<String, String> data = (HashMap<String, String>) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>"); if (data != null) { if (data.get("intaketype") == null) { formSelection.setWidgetValue("Basic"); handleFormSelection(); Util.populateForm(basicFormFields, data); if (data.get("ciisinsured") != null) callinPatientCoverages.loadCoverageData(1, data); btnAdd.setText("Modify"); } } } else { } } } }); } catch (RequestException e) { } } else { // TODO NORMAL MODE STUFF } }
From source file:org.freemedsoftware.gwt.client.screen.CallInScreen.java
License:Open Source License
protected void unarchiveEntry(final Integer callinId) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO STUBBED MODE STUFF } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { JsonUtil.jsonify(callinId) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.module.Callin.GetRecord", params))); try {/*w w w.jav a 2 s. com*/ builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { } public void onResponseReceived(Request request, Response response) { populate(searchCriteria); tabPanel.selectTab(1); selectedEntryId = callinId; modifyEntry(callinId); } }); } catch (RequestException e) { } } else { // TODO NORMAL MODE STUFF } }
From source file:org.freemedsoftware.gwt.client.screen.CallInScreen.java
License:Open Source License
public void populate(HashMap<String, String> criteria) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO: handle stubbed } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { callInTable.showloading(true);/*from w w w. j a v a 2 s .c o m*/ String[] params = {}; if (criteria != null && criteria.size() > 0) { String[] tempParams = { JsonUtil.jsonify(criteria) }; params = tempParams; } RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL .encode(Util.getJsonRequest("org.freemedsoftware.module.Callin.GetAllWithInsurance", 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) { callInTable.clearAllSelections(); callInTable.loadData(result); } else { callInTable.showloading(false); } } else { } } }); } catch (RequestException e) { GWT.log("Exception", e); } } else { getProxy().GetReports(locale, new AsyncCallback<HashMap<String, String>[]>() { public void onSuccess(HashMap<String, String>[] r) { callInTable.loadData(r); } public void onFailure(Throwable t) { GWT.log("Exception", t); } }); } }