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.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 a v a 2 s. c o 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.ja v a 2s . 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 (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.RemittBillingWidget.java
License:Open Source License
public void getFile(final String name) { String[] params = { "output", name, "html" }; Window.open(URL.encode(Util.getJsonRequest("org.freemedsoftware.api.Remitt.GetFile", params)), name, ""); }
From source file:org.freemedsoftware.gwt.client.widget.RemittReportsWidget.java
License:Open Source License
public void loadMonthsInfo() { allReportTable = new FlexTable(); allReportTable.setWidth("80%"); reportsPanel.clear();/*from w w w . j a va 2 s . co m*/ reportsPanel.add(allReportTable); Util.callModuleMethod("RemittBillingTransport", "getMonthsInfo", (Integer) null, new CustomRequestCallback() { @Override public void onError() { } @SuppressWarnings("unchecked") @Override public void jsonifiedData(Object data) { if (data != null) { final HashMap<String, String>[] result = (HashMap[]) data; for (int i = 0; i < result.length; i++) { int row = i / 2; int col = i % 2; VerticalPanel reportPanel = new VerticalPanel(); reportPanel.setSpacing(10); reportPanel.setWidth("70%"); HorizontalPanel hpanel = new HorizontalPanel(); hpanel.setSpacing(5); final Label expandLb = new Label("+"); final CustomTable reportsInfoTable = new CustomTable(); reportsInfoTable.setAllowSelection(false); reportsInfoTable.setWidth("100%"); reportsInfoTable.addColumn(_("Report"), "filename"); reportsInfoTable.addColumn(_("Size"), "filesize"); reportsInfoTable.addColumn(_("Date Sent"), "inserted"); reportsInfoTable.addColumn(_("Action"), "action"); reportsInfoTable .setTableWidgetColumnSetInterface(new TableWidgetColumnSetInterface() { @Override public Widget setColumn(String columnName, final HashMap<String, String> data) { if (columnName.compareTo("action") == 0) { HorizontalPanel actionPanel = new HorizontalPanel(); actionPanel.setSpacing(5); HTML htmlLedger = new HTML("<a href=\"javascript:undefined;\">" + _("View") + "</a>"); htmlLedger.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent arg0) { String[] params = { "output", data.get("filename"), "html" }; Window.open(URL.encode(Util.getJsonRequest( "org.freemedsoftware.api.Remitt.GetFile", params)), data.get("filename"), ""); } }); HTML htmlReSend = null; if (data.get("originalId") != null) { htmlReSend = new HTML("<a href=\"javascript:undefined;\">" + _("Re-Send") + "</a>"); htmlReSend.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent arg0) { CustomRequestCallback cb = new CustomRequestCallback() { @Override public void onError() { } @Override public void jsonifiedData(Object data) { rebillPanel.setVisible(false); reportsPanel.setVisible(true); loadMonthsInfo(); } }; reportsPanel.setVisible(false); rebillPanel.clear(); HashSet<String> hs = new HashSet<String>(); hs.add(data.get("originalId")); RemittBillingWidget billClaimsWidget = new RemittBillingWidget( hs, cb, BillingType.REBILL); rebillPanel.add(billClaimsWidget); rebillPanel.setVisible(true); } }); } else { htmlReSend = new HTML( "<a href=\"javascript:undefined;\" style=\"cursor:default;color: blue;\">" + _("Re-Send") + "</a>"); } actionPanel.add(htmlLedger); actionPanel.add(htmlReSend); return actionPanel; } else if (columnName.compareTo("inserted") == 0) { Label lb = new Label(data.get("inserted").substring(0, 10)); return lb; } else { return (Widget) null; } } }); reportsInfoTable.setVisible(false); expandLb.getElement().getStyle().setCursor(Cursor.POINTER); final int index = i; expandLb.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent arg0) { if (expandLb.getText().trim().equals("+")) { expandLb.setText("-"); reportsInfoTable.setVisible(true); loadReportsDetails(result[index].get("month"), reportsInfoTable); } else { expandLb.setText("+"); reportsInfoTable.setVisible(false); } } }); hpanel.setWidth("100%"); hpanel.setStyleName(AppConstants.STYLE_TABLE_HEADER); Label infoLb = new Label(result[i].get("month")); hpanel.add(expandLb); hpanel.add(infoLb); hpanel.setCellWidth(expandLb, "5px"); reportPanel.add(hpanel); reportPanel.add(reportsInfoTable); allReportTable.setWidget(row, col, reportPanel); allReportTable.getFlexCellFormatter().setVerticalAlignment(row, col, HasVerticalAlignment.ALIGN_TOP); // panel.add(); // panel.add(reportsInfoTable); } } } }, "HashMap<String,String>[]"); }
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 w w w.j a v a 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 w ww . java2 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 w w . ja v a 2s . 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 = { 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. * /*ww w. ja 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;//from w w w . ja va 2s. c o m 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();//from w w w . jav a 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 = { 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) { } }); } } }