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.screen.PreferencesScreen.java
License:Open Source License
public void changePassword() { String[] params = { newPassword.getText() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.core.User.setPassword", params))); try {//from w w w. ja v 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 (Util.checkValidSessionResponse(response.getText())) { if (200 == response.getStatusCode()) { Util.showInfoMsg("PreferencesScreen", _("Password changed successfully.")); currentPassword.setText(""); newPassword.setText(""); confirmNewPassword.setText(""); Util.closeTab(getPreferencesScreen()); } else Util.showErrorMsg("FaxSubsystem", _("Password change failed.")); } } }); } catch (RequestException e) { Window.alert(e.toString()); } }
From source file:org.freemedsoftware.gwt.client.screen.PreferencesScreen.java
License:Open Source License
public void populateProviderGroupList() { if (Util.getProgramMode() == ProgramMode.STUBBED) { } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { "ProviderGroups" }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest( "org.freemedsoftware.api.ModuleInterface.ModuleSupportPicklistMethod", params))); try {// ww w.j a v a 2 s.co 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 (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) { providerGroupList.clear(); Set<String> keys = result.keySet(); Iterator<String> iter = keys.iterator(); providerGroupList.addItem("", ""); while (iter.hasNext()) { final String key = (String) iter.next(); final String val = (String) result.get(key); JsonUtil.debug(val); providerGroupList.addItem(val, key); } providerGroupList.setWidgetValue( CurrentState.getUserConfig("providerGroup", "String") + ""); } 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 { } }
From source file:org.freemedsoftware.gwt.client.screen.ReportingScreen.java
License:Open Source License
public void populate() { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO: handle stubbed } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { reportTable.showloading(true);/* w w w . java 2s .co m*/ String[] params = { locale, "reporting_engine" }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.module.Reporting.GetReports", 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) { reportTable.loadData(result); } else { reportTable.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) { reportTable.loadData(r); } public void onFailure(Throwable t) { GWT.log("Exception", t); } }); } }
From source file:org.freemedsoftware.gwt.client.screen.ReportingScreen.java
License:Open Source License
/** * Get parameters for a specific report by uuid. * //from w w w . j av a 2 s.c o m * @param uuid */ public void getReportInformation(String uuid) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO: handle stubbed } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { uuid }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.Reporting.GetReportParameters", 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) { populateReportParameters(result); } } else { } } }); } catch (RequestException e) { GWT.log("Exception", e); } } else { getProxy().GetReportParameters(uuid, new AsyncCallback<HashMap<String, String>>() { public void onSuccess(HashMap<String, String> r) { populateReportParameters(r); } public void onFailure(Throwable t) { GWT.log("Exception", t); } }); } }
From source file:org.freemedsoftware.gwt.client.screen.RxRefillScreen.java
License:Open Source License
public RxRefillScreen() { super(moduleName); final VerticalPanel verticalPanel = new VerticalPanel(); initWidget(verticalPanel);//from w w w. j a v a 2s .c o m verticalPanel.setSize("100%", "100%"); verticalPanel.setSpacing(10); //top_Label_Horizontal_Panel starts final HorizontalPanel horizontalPanel = new HorizontalPanel(); verticalPanel.add(horizontalPanel); horizontalPanel.setSize("100%", "100%"); final Label reRefillLabel = new Label(_("Prescription Refill Request")); horizontalPanel.add(reRefillLabel); reRefillLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); //top_Label_Horizontal_Panel ends //patient_TextField_Horizontal_Panel starts final HorizontalPanel horizontalPanel1 = new HorizontalPanel(); verticalPanel.add(horizontalPanel1); horizontalPanel1.setSize("100%", "100%"); final Label patientLabel = new Label(_("Patient") + ":"); horizontalPanel1.add(patientLabel); patientLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); horizontalPanel1.setCellWidth(patientLabel, "5%"); patient = new PatientWidget(); patient.setWidth("250"); patient.addChangeHandler(new ValueChangeHandler<Integer>() { @Override public void onValueChange(ValueChangeEvent<Integer> event) { Integer val = ((PatientWidget) event.getSource()).getValue(); patientId = val; // Log.debug("Patient value = " + val.toString()); try { if (val.compareTo(new Integer(0)) != 0) { //spawnPatientScreen(val, wSmartSearch.getText()); //clearForm(); } } catch (Exception e) { // Don't do anything if no patient is declared GWT.log("Caught exception", e); } } }); SuggestBox suggestbox = new SuggestBox(null);//new SuggestBox(createPatientsOracle()); horizontalPanel1.add(patient); horizontalPanel1.setCellHorizontalAlignment(patient, HasHorizontalAlignment.ALIGN_LEFT); //patient_TextField_Horizontal_Panel ends //note_TextField_Horizontal_Panel starts final HorizontalPanel horizontalPanel2 = new HorizontalPanel(); verticalPanel.add(horizontalPanel2); horizontalPanel2.setSize("100%", "100%"); final Label noteLabel = new Label(_("Note") + ":"); horizontalPanel2.add(noteLabel); noteLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); horizontalPanel2.setCellWidth(noteLabel, "5%"); noteBox = new TextArea(); noteBox.setPixelSize(250, 200); horizontalPanel2.add(noteBox); horizontalPanel2.setCellHorizontalAlignment(noteBox, HasHorizontalAlignment.ALIGN_LEFT); //note_TextField_Horizontal_Panel ends //buttons_Horizontal_Panel_Container starts final HorizontalPanel buttonPanelContainer = new HorizontalPanel(); buttonPanelContainer.setWidth("30%"); verticalPanel.add(buttonPanelContainer); //buttons_Horizontal_Panel starts final HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanelContainer.add(buttonPanel); buttonPanelContainer.setCellHorizontalAlignment(buttonPanel, HasHorizontalAlignment.ALIGN_CENTER); // verticalPanel.setCellHorizontalAlignment(buttonPanel, HasHorizontalAlignment.ALIGN_RIGHT); final CustomButton submitButton = new CustomButton(_("Submit Request"), AppConstants.ICON_ADD); submitButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent evt) { submitButton.setEnabled(false); // Add String[] params = { JsonUtil.jsonify(populateHashMap()) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.module.RxRefillRequest.add", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { Integer r = (Integer) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "Integer"); if (r != 0) { submitButton.setEnabled(true); noteBox.setText("");// clearing form horizontalPanel1.add(patient);//clearing form CurrentState.getToaster().addItem("RxRefillScreen", _("Prescription refill successfully added.")); } } else { CurrentState.getToaster().addItem("RxRefillScreen", _("Adding prescription refill failed.")); } } }); } catch (RequestException e) { } retrieveData(); } }); buttonPanel.add(submitButton); final CustomButton cancelButton = new CustomButton(_("Cancel"), AppConstants.ICON_CANCEL); buttonPanel.add(cancelButton); //buttons_Horizontal_Panel ends final HorizontalPanel buttonPanel2 = new HorizontalPanel(); verticalPanel.add(buttonPanel2); final HorizontalPanel buttonPanelContainer2 = new HorizontalPanel(); buttonPanel2.add(buttonPanelContainer2); if (CurrentState.getUserType().equalsIgnoreCase(AppConstants.USER_TYPE_PROVIDER)) { final CustomButton refillButton = new CustomButton("RxRefill"); buttonPanelContainer2.add(refillButton); refillButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent evt) { if (rxRefillTable.getSelectedCount() < 1) Window.alert(_("Please select an entry.")); else { List<String> slectedItems = rxRefillTable.getSelected(); Iterator<String> itr = slectedItems.iterator();// Get all // selected // items // from // custom // table // btnAdd.setText("Modify"); selectedEntryId = Integer.parseInt(itr.next()); showRefillPopup(); } } }); } rxRefillTable = new CustomTable(); rxRefillTable.setSize("100%", "100%"); verticalPanel.add(rxRefillTable); if (CurrentState.getUserType().equalsIgnoreCase(AppConstants.USER_TYPE_PROVIDER)) rxRefillTable.addColumn(_("Selected"), "selected"); rxRefillTable.addColumn(_("Date"), "stamp"); // col 0 rxRefillTable.addColumn(_("User"), "user"); // col 1 rxRefillTable.addColumn(_("Patient"), "patient"); // col 2 // rxRefillTable.addColumn("RX Orig", "rxorig"); // col 3 rxRefillTable.addColumn(_("Note"), "note"); // col 4 rxRefillTable.addColumn(_("Approved"), "approved");// col 5 rxRefillTable.addColumn(_("Locked"), "locked"); // col 6 retrieveData(); rxRefillTable.setTableWidgetColumnSetInterface(new TableWidgetColumnSetInterface() { public Widget setColumn(String columnName, HashMap<String, String> data) { Integer id = Integer.parseInt(data.get("id")); if (CurrentState.getUserType().equalsIgnoreCase(AppConstants.USER_TYPE_PROVIDER)) { if (columnName.compareTo("selected") == 0) { CheckBox c = new CheckBox(); c.addClickHandler(getRxRefillScreen()); checkboxStack.put(c, id); return c; } } return (Widget) null; } }); Util.setFocus(patient); }
From source file:org.freemedsoftware.gwt.client.screen.RxRefillScreen.java
License:Open Source License
public void retrieveData() { if (Util.getProgramMode() == ProgramMode.STUBBED) { // Runs in STUBBED MODE => Feed with Sample Data // HashMap<String, String>[] sampleData = getSampleData(); // loadData(sampleData); } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { rxRefillTable.showloading(true); // Use JSON-RPC to retrieve the data String[] requestparams = {}; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.RxRefillRequest.GetAll", requestparams))); try {//w w w. j ava 2s . c om builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { JsonUtil.debug(request.toString()); } @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) { loadData(data); } else { rxRefillTable.showloading(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.SupportDataManagementScreen.java
License:Open Source License
@SuppressWarnings("unchecked") public void populateData() { try {//from w w w .j a v a 2 s . c om sortableTable.clearData(); } catch (Exception ex) { JsonUtil.debug(ex.toString()); } sortableTable.showloading(true); if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO: populate in stubbed mode } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { moduleName, MINIMUM_RECORDS_LIMIT.toString(), (searchText.getText().length() >= KEYWORD_LENGTH_LIMIT) ? wField.getWidgetValue() : "", (searchText.getText().length() >= KEYWORD_LENGTH_LIMIT) ? searchText.getText() : "" }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.api.ModuleInterface.ModuleGetRecordsMethod", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Util.showErrorMsg("SupportDataScreen", _("Could not load list of support data modules.")); } public void onResponseReceived(Request request, Response response) { if (Util.checkValidSessionResponse(response.getText())) { if (200 == response.getStatusCode()) { HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]"); sortableTable.loadData(r); } else { Util.showErrorMsg("SupportDataScreen", _("Could not load list of support data modules.")); } sortableTable.showloading(false); } } }); } catch (RequestException e) { sortableTable.showloading(false); Window.alert(e.toString()); } } else { ModuleInterfaceAsync proxy = null; try { proxy = (ModuleInterfaceAsync) Util.getProxy("org.freemedsoftware.gwt.client.Api.ModuleInterface"); } catch (Exception e) { GWT.log("Exception", e); } proxy.ModuleGetRecordsMethod(moduleName, MINIMUM_RECORDS_LIMIT, (searchText.getText().length() > 2) ? wField.getWidgetValue() : "", (searchText.getText().length() >= KEYWORD_LENGTH_LIMIT) ? searchText.getText() : "", new AsyncCallback<HashMap<String, String>[]>() { public void onSuccess(HashMap<String, String>[] res) { sortableTable.loadData(res); sortableTable.showloading(false); } public void onFailure(Throwable t) { Util.showErrorMsg("SupportDataScreen", _("Could not load list of support data modules.")); sortableTable.showloading(false); } }); } }
From source file:org.freemedsoftware.gwt.client.screen.SupportDataScreen.java
License:Open Source License
@SuppressWarnings("unchecked") public void populate() { if (Util.getProgramMode() == ProgramMode.STUBBED) { List<HashMap<String, String>> r = new ArrayList<HashMap<String, String>>(); String[][] stockModules = { { "AppointmentTemplates", _("Appointment Templates") }, { "ClaimTypes", _("Claim Types") }, { "CoverageTypes", _("Coverage Types") } }; for (int iter = 0; iter < stockModules.length; iter++) { HashMap<String, String> a = new HashMap<String, String>(); a.put("module_class", stockModules[iter][0]); a.put("module_name", stockModules[iter][1]); a.put("module_version", "0.0"); r.add(a);//from ww w . ja va 2 s.c om } sortableTable.loadData((HashMap<String, String>[]) r.toArray(new HashMap<?, ?>[0])); } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { sortableTable.showloading(true); String[] params = { "SupportModule", "" }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.api.TableMaintenance.GetModules", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Util.showErrorMsg("SupportDataScreen", _("Could not load list of support data modules.")); } public void onResponseReceived(Request request, Response response) { if (Util.checkValidSessionResponse(response.getText())) { if (200 == response.getStatusCode()) { HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]"); sortableTable.loadData(r); } else { sortableTable.showloading(false); Util.showErrorMsg("SupportDataScreen", _("Could not load list of support data modules.")); } } } }); } catch (RequestException e) { Window.alert(e.toString()); } } else { TableMaintenanceAsync proxy = null; try { proxy = (TableMaintenanceAsync) Util .getProxy("org.freemedsoftware.gwt.client.Api.TableMaintenance"); } catch (Exception e) { GWT.log("Exception", e); } proxy.GetModules("SupportModule", "", false, new AsyncCallback<HashMap<String, String>[]>() { public void onSuccess(HashMap<String, String>[] res) { sortableTable.loadData(res); } public void onFailure(Throwable t) { Util.showErrorMsg("SupportDataScreen", _("Could not load list of support data modules.")); } }); } }
From source file:org.freemedsoftware.gwt.client.screen.ToolsScreen.java
License:Open Source License
public void populate() { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO: handle stubbed } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { toolTable.showloading(true);/* ww w . j av a 2 s. c o m*/ String[] params = {}; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.module.Tools.GetTools", 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) { toolTable.loadData(result); } else { toolTable.showloading(false); } } else { } } }); } catch (RequestException e) { GWT.log("Exception", e); } } else { // TODO: Make this work with GWT-RPC } }
From source file:org.freemedsoftware.gwt.client.screen.TriageScreen.java
License:Open Source License
protected void createPatient(Integer clinicRegistrationId) { if (Util.getProgramMode() == ProgramMode.STUBBED) { } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { JsonUtil.jsonify(clinicRegistrationId) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.ClinicRegistration.createPatient", params))); try {// w w w . j ava 2s . c o m builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Util.showInfoMsg("TriageScreen", _("Failed to create new patient record.")); } public void onResponseReceived(Request request, Response response) { if (Util.checkValidSessionResponse(response.getText())) { if (200 == response.getStatusCode()) { String raw = (String) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "String"); Integer r = null; try { r = Integer.parseInt(raw); } catch (Exception ex) { JsonUtil.debug("Unable to parse returned patient id"); } if (r != null) { Util.showInfoMsg("TriageScreen", _("New patient record created.")); loadVitalsScreen(r); } else { Util.showInfoMsg("TriageScreen", _("Failed to create new patient record.")); } } else { Util.showInfoMsg("TriageScreen", _("Failed to create new patient record.")); } } } }); } catch (RequestException e) { JsonUtil.debug(e.getMessage()); Util.showInfoMsg("TriageScreen", _("Failed to create new patient record.")); } } else { JsonUtil.debug("NOT IMPLEMENTED YET"); } }