Example usage for com.google.gwt.http.client URL encode

List of usage examples for com.google.gwt.http.client URL encode

Introduction

In this page you can find the example usage for com.google.gwt.http.client URL encode.

Prototype

public static String encode(String decodedURL) 

Source Link

Document

Returns a string where all characters that are not valid for a complete URL have been escaped.

Usage

From source file:org.freemedsoftware.gwt.client.widget.CustomMulltiSelectListBox.java

License:Open Source License

public void populateMultiList(String sval) {
    selVal = sval;//w  w  w. j a  v  a 2s.  co m
    if (Util.getProgramMode() == ProgramMode.STUBBED) {

    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { module };
        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(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) {
                                multiLBox.clear();
                                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);
                                    JsonUtil.debug(val);
                                    multiLBox.addItem(val, key);
                                    // addKeyValuePair(items, val, key);
                                }
                                if (!(selVal == null || selVal.equals("")))
                                    setValue();
                                // 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 {

    }
}

From source file:org.freemedsoftware.gwt.client.widget.DjvuViewer.java

License:Open Source License

/**
 * Retrieve the current number of pages for the internal document.
 *//* w  ww  .  ja v a  2s .  co  m*/
protected boolean getNumberOfPages() {
    if (internalId.intValue() == 0) {
        GWT.log("getNUmberOfPages called without initializing internalId", null);
        return false;
    }
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        numberOfPages = 1;
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { JsonUtil.jsonify(internalId) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest(resolveNamespace() + ".NumberOfPages", 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 != null) {
                            numberOfPages = r;
                            try {
                                loadPage(1);
                            } catch (Exception e) {
                                JsonUtil.debug(e.getMessage());
                            }
                            setVisible(true);
                        }
                    } else {
                    }
                }
            });
        } catch (RequestException e) {
        }
    } else {
        if (viewerType == UNFILED_DOCUMENTS) {
            UnfiledDocumentsAsync p = null;
            try {
                p = (UnfiledDocumentsAsync) Util
                        .getProxy("org.freemedsoftware.gwt.client.Module.UnfiledDocuments");
            } catch (Exception e) {
                GWT.log("Exception", e);
            }
            p.NumberOfPages(internalId, new AsyncCallback<Integer>() {
                public void onSuccess(Integer o) {
                    numberOfPages = o.intValue();
                }

                public void onFailure(Throwable t) {
                    GWT.log("Exception", t);
                }
            });
        }

        if (viewerType == UNREAD_DOCUMENTS) {
            UnreadDocumentsAsync p = null;
            try {
                p = (UnreadDocumentsAsync) Util
                        .getProxy("org.freemedsoftware.gwt.client.Module.UnreadDocuments");
            } catch (Exception e) {
                GWT.log("Exception", e);
            }
            p.NumberOfPages(internalId, new AsyncCallback<Integer>() {
                public void onSuccess(Integer o) {
                    numberOfPages = o.intValue();
                }

                public void onFailure(Throwable t) {
                    GWT.log("Exception", t);
                }
            });
        }
        if (viewerType == SCANNED_DOCUMENTS) {
            // TODO: make this work for scanned documents
        }
    }
    return true;
}

From source file:org.freemedsoftware.gwt.client.widget.DocumentBox.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);//from w  ww  .j av  a 2s  .  co  m
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        wDocuments.showloading(true);
        // Use JSON-RPC to retrieve the data
        String[] documentparams = {};

        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.module.UnfiledDocuments.GetAll", documentparams)));
        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) {
                            loadData(data);
                        } else
                            wDocuments.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.DrugWidget.java

License:Open Source License

protected void populateStrength(Integer drugValue, final Command after) {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        drugStrength.addItem("125MG", "1");
        drugStrength.addItem("500MG", "2");
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { drugValue.toString() };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL
                .encode(Util.getJsonRequest("org.freemedsoftware.module.NDCLexicon.DosagesForDrug", params)));
        try {//  w  ww  .j  av 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 (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            String[][] r = (String[][]) JsonUtil
                                    .shoehornJson(JSONParser.parseStrict(response.getText()), "String[][]");
                            if (r != null) {
                                drugStrength.clear();
                                for (int iter = 0; iter < r.length; iter++) {
                                    drugStrength.addItem(r[iter][0], r[iter][1]);
                                }
                                if (after != null) {
                                    after.execute();
                                }
                            }
                        } else {
                            GWT.log("Result " + response.getStatusText(), null);
                        }
                    }
                }
            });
        } catch (RequestException e) {
            GWT.log("Exception thrown: ", e);
        }
    } else {
        // FIXME: GWT-RPC NOT IMPLEMENTED YET!
    }
}

From source file:org.freemedsoftware.gwt.client.widget.EMRModuleWidget.java

License:Open Source License

/**
 * Set value of current widget based on integer value, asynchronously.
 * /*  w w w.j a  v  a2s  .c  o  m*/
 * @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);
                                }
                            } 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.EMRModuleWidget.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();/*from   w  ww.j a v  a2  s.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) {
        String[] params = { moduleName, patientId.toString(), req };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util
                .getJsonRequest("org.freemedsoftware.api.ModuleInterface.EMRSupportPicklistMethod", 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.EMRModuleWidget.java

License:Open Source License

@Override
public void getTextForValue(Integer val) {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        searchBox.setText("Hackenbush, Hugo Z (STUB)");
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { moduleName, val.toString() };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.api.ModuleInterface.ModuleToTextMethod", params)));
        try {/*from w  w w . j a v  a 2  s .  c  om*/
            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 (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            String result = (String) JsonUtil
                                    .shoehornJson(JSONParser.parseStrict(response.getText()), "String");
                            if (result != null) {
                            }
                        } 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.ModuleToTextMethod(moduleName, val, new AsyncCallback<String>() {
            public void onSuccess(String r) {
                searchBox.setText(r);
            }

            public void onFailure(Throwable t) {
                GWT.log("Exception", t);
            }
        });
    }
}

From source file:org.freemedsoftware.gwt.client.widget.EncounterTemplateWidget.java

License:Open Source License

public void loadTemplates() {
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {

        String[] params = {};//w ww .j av a 2 s.com
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.module.EncounterNotesTemplate.getTemplates", 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()) {
                        try {
                            HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                    JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]");
                            if (r != null) {
                                if (r.length > 0) {
                                    templatesCustomTable.loadData(r);
                                } else {
                                }
                            } else {

                            }
                        } catch (Exception e) {

                        }

                    } else {

                    }
                }
            });
        } catch (RequestException e) {
        }
    }
}

From source file:org.freemedsoftware.gwt.client.widget.EncounterTemplateWidget.java

License:Open Source License

public void getTemplateValues(String templateId) {
    reset();/*from   w  ww  .j  a  v  a 2  s.com*/
    tabPanel.selectTab(0);
    currentTemplate = templateId;
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { templateId };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util
                .getJsonRequest("org.freemedsoftware.module.EncounterNotesTemplate.getTemplateInfo", 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()) {
                        try {
                            HashMap<String, String> r = (HashMap<String, String>) JsonUtil.shoehornJson(
                                    JSONParser.parseStrict(response.getText()), "HashMap<String,String>");
                            if (r != null) {
                                templateValueMap = r;
                                String secStr = r.get("pnotestsections");
                                HashMap<String, List<String>> secFldMap = (HashMap<String, List<String>>) JsonUtil
                                        .shoehornJson(JSONParser.parseStrict(secStr), "HashMap<String,List>");
                                tbEncTempName.setText(templateValueMap.get("pnotestname"));
                                if (templateValueMap.get("pnotesttype") != null) {
                                    radType.setWidgetValue(templateValueMap.get("pnotesttype"));
                                }
                                templateWidget.loadValues(secFldMap);
                            } else {

                            }
                        } catch (Exception e) {

                        }

                    } else {

                    }
                }
            });
        } catch (RequestException e) {
        }
    }
}

From source file:org.freemedsoftware.gwt.client.widget.EncounterTemplateWidget.java

License:Open Source License

public void deleteTemplate(String id) {
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { id };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.module.EncounterNotes.del", params)));

        try {//ww w  . j av a  2 s  .  c o  m
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                public void onResponseReceived(Request request, Response response) {

                    if (200 == response.getStatusCode()) {
                        try {
                            Boolean r = (Boolean) JsonUtil
                                    .shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean");
                            if (r) {
                                Util.showInfoMsg("EncounterNotesTemplate",
                                        "Encounter Note Template Successfully Deleted.");
                                loadTemplates();
                            }

                        } catch (Exception e) {

                        }

                    } else {

                    }
                }
            });
        } catch (RequestException e) {
        }
    }
}