Example usage for com.google.gwt.http.client RequestBuilder POST

List of usage examples for com.google.gwt.http.client RequestBuilder POST

Introduction

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

Prototype

Method POST

To view the source code for com.google.gwt.http.client RequestBuilder POST.

Click Source Link

Document

Specifies that the HTTP POST method should be used.

Usage

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

License:Open Source License

@Override
public void getTextForValue(Integer val) {
    if (val > 0) {
        if (Util.getProgramMode() == ProgramMode.STUBBED) {
            searchBox.setText("Cranston GOP (Cranston, RI)(STUB)");
        } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
            textBox.setEnabled(false);/*ww  w  .jav a2s  .  c o m*/
            String[] params = { val.toString() };
            RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                    URL.encode(Util.getJsonRequest("org.freemedsoftware.module.Pharmacy.To_Text", 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);
                                }
                            } else {
                                Window.alert(response.toString());
                            }
                        }
                    }
                });
            } catch (RequestException e) {
                textBox.setEnabled(true);
                Window.alert(e.toString());
            }
        } else {
            // TODO GWT STUFF
        }
    }
}

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

License:Open Source License

public void loadSelectedProcedureInfo() {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {

    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { procs.toString() };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.api.ClaimLog.getProceduresInfo", params)));
        try {//from   w ww.  j a  v  a 2  s  .c om
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    Window.alert(ex.toString());
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(Request request, Response response) {

                    if (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            try {
                                HashMap<String, String>[] result = (HashMap<String, String>[]) JsonUtil
                                        .shoehornJson(JSONParser.parseStrict(response.getText()),
                                                "HashMap<String,String>[]");
                                if (result != null) {
                                    if (result.length > 0) {
                                        proceduresInfoTable.loadData(result);
                                    }
                                }
                            } catch (Exception e) {

                            }
                        } else {
                        }
                    }
                }
            });
        } catch (RequestException e) {
            Window.alert(e.toString());
        }

    } else {
    }
}

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

License:Open Source License

public void postCheck(HashMap<String, String>[] maps) {
    final PostCheckWidget pcw = this;
    if (Util.getProgramMode() == ProgramMode.STUBBED) {

    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        // String[] params = { "" + payerWidget.getStoredValue(),
        // JsonUtil.jsonify(tbCheckNo.getText()),
        // JsonUtil.jsonify(maps) };
        String[] params = { "", JsonUtil.jsonify(tbCheckNo.getText()), JsonUtil.jsonify(maps) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.api.ClaimLog.post_check", params)));
        try {/*  www .j av  a  2  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 (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            pcw.removeFromParent();
                            callback.jsonifiedData("update");
                        } else {
                        }
                    }
                }
            });
        } catch (RequestException e) {
            Window.alert(e.toString());
        }

    } else {
    }
}

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

License:Open Source License

public void showStaff() {

    cleanView();//from ww w . j a v a 2s  . c  o  m

    flexTable.getFlexCellFormatter().setColSpan(1, 0, 1);

    final PatientWidget patientWidget = new PatientWidget();
    flexTable.setWidget(1, 1, patientWidget);

    final Label selectionLabel = new Label(_("Select a Patient") + ":");
    flexTable.setWidget(1, 0, selectionLabel);

    final Label textLabel = new Label(_("Add an optional note") + ":");
    flexTable.setWidget(2, 0, textLabel);

    final TextBox textBox = new TextBox();
    flexTable.setWidget(2, 1, textBox);
    textBox.setWidth("100%");

    final CustomButton sendButton = new CustomButton(_("Send Request"), AppConstants.ICON_SEND);
    flexTable.setWidget(3, 1, sendButton);

    sendButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent evt) {
            String msg = "";
            if (Integer.parseInt(patientWidget.getStoredValue()) == 0)
                msg = _("Please select a patient.");
            if (textBox.getText().trim().length() == 0)
                msg += "\n" + _("Please add a short note.");

            if (msg.length() > 0) {
                Util.showErrorMsg(moduleName, msg);
                return;
            }

            patid = patientWidget.value;

            HashMap<String, String> data = new HashMap<String, String>();
            // data.put("id", "some stuff"); not needed??
            data.put("provider", Integer.toString(CurrentState.getDefaultProvider()));
            data.put("note", textBox.getText());
            data.put("patient", Integer.toString(patid));
            // send stuff
            if (Util.getProgramMode() == ProgramMode.STUBBED) {
                // do nothing - we just save the stuff
            } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
                String[] params = { JsonUtil.jsonify(data) };
                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) {
                            Util.showErrorMsg("PrescriptionRefillBox",
                                    _("Error adding refill request.") + ex.toString());
                        }

                        public void onResponseReceived(Request request, Response response) {
                            if (200 == response.getStatusCode()) {
                                Integer r = (Integer) JsonUtil
                                        .shoehornJson(JSONParser.parseStrict(response.getText()), "Integer");
                                if (r != 0) {
                                    Util.showInfoMsg("PrescriptionRefillBox",
                                            _("Refill request successfully saved."));
                                }
                            } else {
                                Util.showErrorMsg("PrescriptionRefillBox",
                                        _("Error adding prescription refill request."));
                            }
                        }
                    });
                } catch (RequestException e) {
                }

            } else if (Util.getProgramMode() == ProgramMode.NORMAL) {
                // TODO: GWT-RPC still missing
            }

        }

    });
}

From source file:org.freemedsoftware.gwt.client.widget.PrescriptionRefillBox.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) {
        wRequests.showloading(true);/* ww  w.j av  a  2  s  . com*/
        // 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 {
            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
                            wRequests.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.ProviderWidget.java

License:Open Source License

protected void loadSuggestions(String req, final Request r, final Callback cb) {
    if (req.length() < CurrentState.getMinCharCountForSmartSearch())
        return;/*from  w  ww. j  a v a2s.  com*/
    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) {
        String[] params = { req, new Integer(20).toString() };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.module.ProviderModule.InternalPicklist", 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<Integer, String> result = (HashMap<Integer, String>) JsonUtil.shoehornJson(
                                    JSONParser.parseStrict(response.getText()), "HashMap<Integer,String>");
                            if (result != null) {
                                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();
                                    String val = (String) result.get(keyInt);
                                    addKeyValuePair(items, val, key);
                                }
                                cb.onSuggestionsReady(r, new SuggestOracle.Response(items));
                            }
                        }
                    } else {
                        Window.alert(response.toString());
                    }
                }
            });
        } catch (RequestException e) {
            Window.alert(e.toString());
        }
    } else {
        // TODO normal mode code goes here
    }
}

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

License:Open Source License

@Override
public void getTextForValue(Integer val) {
    if (val > 0) {
        if (Util.getProgramMode() == ProgramMode.STUBBED) {
            searchBox.setText("Hackenbush, Hugo Z (STUB)");
        } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
            // textBox.setEnabled(false);
            String[] params = { val.toString() };
            RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL
                    .encode(Util.getJsonRequest("org.freemedsoftware.module.ProviderModule.To_Text", 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());
                    }/*from  w w w  . ja  v a 2s  .  com*/

                    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);
                                }
                            } else {
                                Window.alert(response.toString());
                            }
                        }
                    }
                });
            } catch (RequestException e) {
                // textBox.setEnabled(true);
                Window.alert(e.toString());
            }
        } else {
            // TODO normal mode code goes here
        }
    }
}

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

License:Open Source License

@SuppressWarnings("unchecked")
protected void populate() {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        allergiesTable.clearData();// w  w w  .j  ava 2  s  . c om
        List<HashMap<String, String>> results = new ArrayList<HashMap<String, String>>();
        {
            HashMap<String, String> item1 = new HashMap<String, String>();
            item1.put("allergy", "Penicillin");
            item1.put("reaction", "Swelling");
            item1.put("severity", "Moderate");
            results.add(item1);
        }
        {
            HashMap<String, String> item2 = new HashMap<String, String>();
            item2.put("allergy", "Bee Stings");
            item2.put("reaction", "Swelling");
            item2.put("severity", "Severe");
            results.add(item2);
        }
        {
            HashMap<String, String> item3 = new HashMap<String, String>();
            item3.put("allergy", "Avocado");
            item3.put("reaction", "Hives");
            item3.put("severity", "Moderate");
            results.add(item3);
        }
        allergiesTable.loadData(results.toArray((HashMap<String, String>[]) new HashMap<?, ?>[0]));
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { JsonUtil.jsonify(patientId) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.module.Allergies.GetMostRecent", 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()) {
                        HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]");
                        if (r != null) {
                            allergiesTable.clearData();
                            try {
                                allergiesTable.loadData(r);
                            } catch (Exception e) {
                                GWT.log("Exception", e);
                            }
                        }
                    } else {
                    }
                }
            });
        } catch (RequestException e) {
        }
    } else {
        getProxy().GetMostRecent(patientId, new AsyncCallback<HashMap<String, String>[]>() {
            public void onSuccess(HashMap<String, String>[] m) {
                allergiesTable.clearData();
                try {
                    allergiesTable.loadData(m);
                } catch (Exception e) {
                    GWT.log("Exception", e);
                }
            }

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

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

License:Open Source License

@SuppressWarnings("unchecked")
protected void populate() {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        medicationsTable.clearData();//from   ww w.ja v  a2s  .c o m
        List<HashMap<String, String>> results = new ArrayList<HashMap<String, String>>();
        {
            HashMap<String, String> item1 = new HashMap<String, String>();
            item1.put("mdrug", "Doxycycline");
            item1.put("mdosage", "100mg");
            item1.put("mroute", "Tablet");
            item1.put("minterval", "BID");
            item1.put("prescriber", "Hackenbush, Hugo Z");
            results.add(item1);
        }
        {
            HashMap<String, String> item2 = new HashMap<String, String>();
            item2.put("mdrug", "Keflex");
            item2.put("mdosage", "50mg");
            item2.put("mroute", "Capsule");
            item2.put("minterval", "BID");
            item2.put("prescriber", "Hackenbush, Hugo Z");
            results.add(item2);
        }
        {
            HashMap<String, String> item3 = new HashMap<String, String>();
            item3.put("mdrug", "Feldene");
            item3.put("mdosage", "75mg");
            item3.put("mroute", "Tablet");
            item3.put("minterval", "BID");
            item3.put("prescriber", "Hackenbush, Hugo Z");
            results.add(item3);
        }
        medicationsTable.loadData(results.toArray((HashMap<String, String>[]) new HashMap<?, ?>[0]));
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { JsonUtil.jsonify(patientId) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.api.ModuleInterface.ModuleAddMethod", 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()) {
                        HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]");
                        if (r != null) {
                            medicationsTable.clearData();
                            try {
                                medicationsTable.loadData(r);
                            } catch (Exception e) {
                                GWT.log("Exception", e);
                            }
                        } else {
                            medicationsTable.noItemFound.setVisible(true);
                        }
                    } else {
                    }
                }
            });
        } catch (RequestException e) {
        }
    } else {
        getProxy().GetMostRecent(patientId, new AsyncCallback<HashMap<String, String>[]>() {
            public void onSuccess(HashMap<String, String>[] m) {
                medicationsTable.clearData();
                try {
                    medicationsTable.loadData(m);
                } catch (Exception e) {
                    GWT.log("Exception", e);
                }
            }

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

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

License:Open Source License

public void loadSelectedProcedureInfo() {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {

    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { procs.toString() };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.api.ClaimLog.getProceduresInfo", 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) {
                    Window.alert(ex.toString());
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(Request request, Response response) {

                    if (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            try {
                                HashMap<String, String>[] result = (HashMap<String, String>[]) JsonUtil
                                        .shoehornJson(JSONParser.parseStrict(response.getText()),
                                                "HashMap<String,String>[]");
                                if (result != null) {
                                    if (result.length > 0) {
                                        for (int i = 0; i < result.length; i++) {
                                            HashMap<String, String> hm = new HashMap<String, String>();
                                            procsInfoMap.put(result[i].get("id"), hm);
                                        }
                                        claimsTable.loadData(result);
                                    }
                                }
                            } catch (Exception e) {

                            }
                        } else {
                        }
                    }
                }
            });
        } catch (RequestException e) {
            Window.alert(e.toString());
        }

    } else {
    }
}