List of usage examples for com.google.gwt.jsonp.client JsonpRequestBuilder requestObject
public <T extends JavaScriptObject> JsonpRequest<T> requestObject(String url, AsyncCallback<T> callback)
From source file:net.cbtltd.client.panel.JournalPopup.java
private void getJsonpPay(String tocurrency) { if (ifMessage(AbstractRoot.noOrganizationid(), Level.ERROR, AbstractField.CONSTANTS.errOrganizationid(), processField)//from w w w.j av a 2 s. c o m || ifMessage(AbstractRoot.noActorid(), Level.ERROR, AbstractField.CONSTANTS.errActorid(), processField) || ifMessage(processField.noValue(), Level.ERROR, CONSTANTS.processError(), processField) || ifMessage(eventnameField.noValue(), Level.ERROR, AbstractField.CONSTANTS.errId(), eventnameField) || ifMessage(!entityField.hasValue(Party.CBT_LTD_PARTY), Level.ERROR, CONSTANTS.gatewayCBTError(), entityField) || ifMessage(financeField.noValue(), Level.ERROR, CONSTANTS.financeError(), financeField) || ifMessage(amountField.noValue() || amountField.getValue() <= 0.0, Level.ERROR, CONSTANTS.amountError(), amountField) || ifMessage(cardholderField.noValue(), Level.ERROR, CONSTANTS.cardholderError(), cardholderField) || ifMessage(cardnumberField.noValue(), Level.ERROR, CONSTANTS.cardnumberError(), cardnumberField) || ifMessage(!Finance.isCreditCardNumber(cardnumberField.getValue()), Level.ERROR, CONSTANTS.cardnumberError(), cardnumberField) || ifMessage(cardmonthField.noValue(), Level.ERROR, CONSTANTS.cardmonthError(), cardmonthField) || ifMessage(cardyearField.noValue(), Level.ERROR, CONSTANTS.cardyearError(), cardyearField) || ifMessage(cardcodeField.noValue(), Level.ERROR, CONSTANTS.cardcodeError(), cardcodeField)) { return; } JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); String url = HOSTS.jsonUrl() + "?service=" + JSONRequest.PAY + "&pos=" + Window.Location.getParameter(AbstractRoot.Type.pos.name()) + "&organizationid=" + AbstractRoot.getOrganizationid() + "&financeid=" + financeField.getValue() + "&eventname=" + eventnameField.getValue() + "&amount=" + amountField.getValue() + "¤cy=" + amountField.getUnitvalue() + "&tocurrency=" + tocurrency + "&emailaddress=" + AbstractRoot.getSession().getEmailaddress() + "&cardholder=" + cardholderField.getValue() + "&cardnumber=" + cardnumberField.getValue() + "&cardmonth=" + cardmonthField.getValue() + "&cardyear=" + cardyearField.getValue() + "&cardcode=" + cardcodeField.getValue(); loader.setVisible(true); jsonp.requestObject(url, new AsyncCallback<PayWidgetItem>() { @Override public void onFailure(Throwable caught) { LoadingPopup.getInstance().hide(); loader.setVisible(false); throw new RuntimeException("getJsonpPay:" + caught.getMessage()); } @Override public void onSuccess(PayWidgetItem response) { loader.setVisible(false); message = response.getMessage(); if (response.getState().equalsIgnoreCase(RazorWidget.State.SUCCESS.name())) { finance.setCurrency(amountField.getUnitvalue()); finance.setOwnerid(AbstractRoot.getOrganizationid()); Double amount = Event.round(amountField.getValue() / response.getAmount(), 2); exchangerateField.setValue(amountField.getValue() / amount); amountField.setValue(amount); amountField.setUnitvalue(response.getCurrency()); postPayment(true); state = Event.CREATED; journalSave.execute(); setView(); submitButton.setVisible(false); cancelButton.setVisible(false); } else { AbstractField.addMessage(Level.ERROR, message, cardholderField); } } }); }
From source file:net.cbtltd.client.panel.JournalPopup.java
private void getJsonpReceive(String tocurrency) { if (ifMessage(AbstractRoot.noOrganizationid(), Level.ERROR, AbstractField.CONSTANTS.errOrganizationid(), processField)/* w w w . ja va2 s .co m*/ || ifMessage(AbstractRoot.noActorid(), Level.ERROR, AbstractField.CONSTANTS.errActorid(), processField) || ifMessage(processField.noValue(), Level.ERROR, CONSTANTS.processError(), processField) || ifMessage(eventnameField.noValue(), Level.ERROR, AbstractField.CONSTANTS.errId(), eventnameField) || ifMessage(!financeField.hasValue(Finance.CBT_ZAR_FINANCE), Level.ERROR, CONSTANTS.gatewayZARError(), financeField) || ifMessage(amountField.noValue() || amountField.getValue() <= 0.0, Level.ERROR, CONSTANTS.amountError(), amountField) || ifMessage(cardholderField.noValue(), Level.ERROR, CONSTANTS.cardholderError(), cardholderField) || ifMessage(cardnumberField.noValue(), Level.ERROR, CONSTANTS.cardnumberError(), cardnumberField) || ifMessage(!Finance.isCreditCardNumber(cardnumberField.getValue()), Level.ERROR, CONSTANTS.cardnumberError(), cardnumberField) || ifMessage(cardmonthField.noValue(), Level.ERROR, CONSTANTS.cardmonthError(), cardmonthField) || ifMessage(cardyearField.noValue(), Level.ERROR, CONSTANTS.cardyearError(), cardyearField) || ifMessage(cardcodeField.noValue(), Level.ERROR, CONSTANTS.cardcodeError(), cardcodeField)) { return; } JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); String url = HOSTS.jsonUrl() + "?service=" + JSONRequest.RECEIVE + "&pos=" + Window.Location.getParameter(AbstractRoot.Type.pos.name()) + "&organizationid=" + AbstractRoot.getOrganizationid() + "&financeid=" + financeField.getValue() + "&eventname=" + eventnameField.getValue() + "&amount=" + amountField.getValue() + "¤cy=" + amountField.getUnitvalue() + "&tocurrency=" + tocurrency + "&emailaddress=" + AbstractRoot.getSession().getEmailaddress() + "&cardholder=" + cardholderField.getValue() + "&cardnumber=" + cardnumberField.getValue() + "&cardmonth=" + cardmonthField.getValue() + "&cardyear=" + cardyearField.getValue() + "&cardcode=" + cardcodeField.getValue(); loader.setVisible(true); jsonp.requestObject(url, new AsyncCallback<PayWidgetItem>() { @Override public void onFailure(Throwable caught) { loader.setVisible(false); LoadingPopup.getInstance().hide(); throw new RuntimeException("getJsonpReceive:" + caught.getMessage()); } @Override public void onSuccess(PayWidgetItem response) { loader.setVisible(false); message = response.getMessage(); if (response.hasState(RazorWidget.State.SUCCESS.name())) { finance.setOwnerid(AbstractRoot.getOrganizationid()); postCardReceipt(); state = Event.CREATED; //TODO: FROZEN journalSave.execute(); setView(); submitButton.setVisible(false); cancelButton.setVisible(false); } else { AbstractField.addMessage(Level.ERROR, message, cardholderField); } } }); }
From source file:net.cbtltd.client.panel.ReservationPopup.java
private void getJsonpBook() { JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); String url = HOSTS.jsonUrl() + "?service=" + JSONRequest.BOOK + "&pos=" + Window.Location.getParameter(AbstractRoot.Type.pos.name()) + "&productid=" + productField.getValue() + "&fromdate=" + DF.format(fromtodateField.getValue()) + "&todate=" + DF.format(fromtodateField.getTovalue()) + "&emailaddress=" + emailaddressField.getValue() + "&familyname=" + familynameField.getValue() + "&firstname=" + firstnameField.getValue() + "&cardholder=" + cardholderField.getValue() + "&cardnumber=" + cardnumberField.getValue() + "&cardmonth=" + cardmonthField.getValue() + "&cardyear=" + cardyearField.getValue() + "&cardcode=" + cardcodeField.getValue();// w ww. ja va2s.co m loader.setVisible(true); jsonp.requestObject(url, new AsyncCallback<BookWidgetItem>() { @Override public void onFailure(Throwable caught) { LoadingPopup.getInstance().hide(); loader.setVisible(false); Log.debug("getJsonpBook onFailure"); throw new RuntimeException("Failure:" + caught.getMessage()); } @Override public void onSuccess(BookWidgetItem response) { Log.debug("getJsonpBook onSuccess " + response.string()); loader.setVisible(false); onStateChange(response.getState()); messageField.setVisible(true); if (response.noName()) { messageField.setValue(response.getMessage()); messageField.setTitle(response.getMessage()); } else { StringBuilder sb = new StringBuilder(); sb.append("Reservation Number: " + response.getName()); sb.append("\nArrival Date: " + AbstractRoot.getDF().format(fromtodateField.getValue())); sb.append("\nDeparture Date: " + AbstractRoot.getDF().format(fromtodateField.getTovalue())); sb.append("\nProperty: " + productField.getName()); sb.append("\nPrice for Stay: " + AbstractField.AF.format(response.getQuote()) + " " + response.getCurrency()); sb.append("\nTerms & Conditions\n").append(response.getMessage()); messageField.setValue(sb.toString()); messageField.setTitle(sb.toString()); confirmationReport.getReport().setOrganizationid(response.getOrganizationid()); confirmationReport.getReport().setFromtoname(response.getName()); confirmationReport.setVisible(true); } messageField.setVisible(true); if (response.getAmount() > 0.0) { amountField.setValue(response.getAmount()); amountField.setUnitvalue(response.getCurrency()); } } }); }
From source file:net.cbtltd.client.widget.book.BookWidget.java
private void getJsonpBook() { if (RazorWidget.ifMessage(fromtodateField.noValue(), Level.ERROR, CONSTANTS.fromdateError(), fromtodateField)//from ww w. ja v a2s.com || RazorWidget.ifMessage(fromtodateField.noTovalue(), Level.ERROR, CONSTANTS.todateError(), fromtodateField) || RazorWidget.ifMessage(fromtodateField.isEndBeforeStart(), Level.ERROR, CONSTANTS.endBeforeStartError(), fromtodateField) || RazorWidget.ifMessage(fromtodateField.getDuration(Time.DAY) < 1, Level.ERROR, CONSTANTS.endBeforeStartError(), fromtodateField) || RazorWidget.ifMessage(emailaddressField.noValue(), Level.ERROR, CONSTANTS.emailaddressError(), emailaddressField) || RazorWidget.ifMessage(!Party.isEmailAddress(emailaddressField.getValue()), Level.ERROR, CONSTANTS.emailaddressError(), emailaddressField) || RazorWidget.ifMessage(familynameField.noValue(), Level.ERROR, CONSTANTS.familynameError(), familynameField) || RazorWidget.ifMessage(firstnameField.noValue(), Level.ERROR, CONSTANTS.firstnameError(), firstnameField) || RazorWidget.ifMessage(cardholderField.isVisible() && cardholderField.noValue(), Level.ERROR, CONSTANTS.cardholderError(), cardholderField) || RazorWidget.ifMessage(cardnumberField.isVisible() && cardnumberField.noValue(), Level.ERROR, CONSTANTS.cardnumberError(), cardnumberField) || RazorWidget.ifMessage( cardnumberField.isVisible() && !Finance.isCreditCardNumber(cardnumberField.getValue()), Level.ERROR, CONSTANTS.cardnumberError(), cardnumberField) || RazorWidget.ifMessage(cardmonthField.isVisible() && cardmonthField.noValue(), Level.ERROR, CONSTANTS.cardmonthError(), cardmonthField) || RazorWidget.ifMessage(cardyearField.isVisible() && cardyearField.noValue(), Level.ERROR, CONSTANTS.cardyearError(), cardyearField) || RazorWidget.ifMessage(cardcodeField.isVisible() && cardcodeField.noValue(), Level.ERROR, CONSTANTS.cardcodeError(), cardcodeField)) { return; } JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); String url = HOSTS.jsonUrl() + "?service=" + JSONRequest.BOOK + "&pos=" + pos + "&productid=" + productField.getValue() + "&fromdate=" + RazorWidget.DF.format(fromtodateField.getValue()) + "&todate=" + RazorWidget.DF.format(fromtodateField.getTovalue()) + "&emailaddress=" + emailaddressField.getValue() + "&familyname=" + familynameField.getValue() + "&firstname=" + firstnameField.getValue() + "¬es=" + notesField.getValue() + "&cardholder=" + cardholderField.getValue() + "&cardnumber=" + cardnumberField.getValue() + "&cardmonth=" + cardmonthField.getValue() + "&cardyear=" + cardyearField.getValue() + "&cardcode=" + cardcodeField.getValue() + "&amount=" + amountField.getValue(); loader.setVisible(true); jsonp.requestObject(url, new AsyncCallback<BookWidgetItem>() { @Override public void onFailure(Throwable x) { LoadingPopup.getInstance().hide(); loader.setVisible(false); setPaymentVisible(false); throw new RuntimeException("getJsonpBook:" + x.getMessage()); } @Override public void onSuccess(BookWidgetItem response) { loader.setVisible(false); if (response.getState().equalsIgnoreCase(RazorWidget.State.SUCCESS.name())) { confirmationReport.getReport().setOrganizationid(response.getOrganizationid()); confirmationReport.getReport().setFromtoname(response.getName()); confirmationReport.setVisible(true); submitButton.setVisible(false); resetButton.setVisible(true); setPaymentVisible(response.getQuote() > 0.0); quoteField.setValue(response.getQuote()); quoteField.setUnitvalue(response.getCurrency()); amountField.setValue(response.getAmount()); amountField.setUnitvalue(response.getCurrency()); StringBuilder sb = new StringBuilder(); sb.append("Reservation Number: " + response.getName()); sb.append("\nArrival Date: " + AbstractRoot.getDF().format(fromtodateField.getValue())); sb.append("\nDeparture Date: " + AbstractRoot.getDF().format(fromtodateField.getTovalue())); sb.append("\nProperty: " + productField.getName()); AbstractField.addMessage(Level.VERBOSE, sb.toString(), emailaddressField); } else { submitButton.setVisible(true); AbstractField.addMessage(Level.ERROR, response.getMessage(), emailaddressField); } } }); }
From source file:net.cbtltd.client.widget.book.BookWidget.java
private void getJsonpParty() { if (emailaddressField.noValue()) { return;/*from w ww . java2 s .com*/ } JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); String url = HOSTS.jsonUrl() + "?service=" + JSONRequest.EMAIL + "&pos=" + pos + "&emailaddress=" + emailaddressField.getValue(); loader.setVisible(true); jsonp.requestObject(url, new AsyncCallback<EmailWidgetItem>() { @Override public void onFailure(Throwable x) { loader.setVisible(false); throw new RuntimeException(Error.party_json + " " + x.getMessage()); } @Override public void onSuccess(EmailWidgetItem response) { loader.setVisible(false); if (response != null) { familynameField.setValue(response.getFamilyname()); firstnameField.setValue(response.getFirstname()); } } }); }
From source file:net.cbtltd.client.widget.book.BookWidget.java
private void getJsonpPriceAvailable() { if (productField.noValue() || fromtodateField.noValue() || fromtodateField.noTovalue() || fromtodateField.isEndBeforeStart() || fromtodateField.getDuration(Time.DAY) < 1) { return;/*www .j a v a 2 s . co m*/ } JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); String url = HOSTS.jsonUrl() + "?service=" + JSONRequest.BOOK_AVAILABLE + "&pos=" + pos + "&productid=" + productField.getValue() + "&fromdate=" + RazorWidget.DF.format(fromtodateField.getValue()) + "&todate=" + RazorWidget.DF.format(fromtodateField.getTovalue()) + "&emailaddress=" + emailaddressField.getValue(); loader.setVisible(true); jsonp.requestObject(url, new AsyncCallback<BookWidgetItem>() { @Override public void onFailure(Throwable x) { loader.setVisible(false); setPaymentVisible(false); throw new RuntimeException(Error.price_json + " " + x.getMessage()); } @Override public void onSuccess(BookWidgetItem response) { loader.setVisible(false); if (response.getState().equalsIgnoreCase(RazorWidget.State.SUCCESS.name())) { setPaymentVisible(response.getQuote() > 0.0); quoteField.setValue(response.getQuote()); quoteField.setUnitvalue(response.getCurrency()); amountField.setValue(response.getAmount()); amountField.setUnitvalue(response.getCurrency()); confirmationReport.setVisible(false); submitButton.setVisible(true); resetButton.setVisible(true); } else { setPaymentVisible(false); AbstractField.addMessage(Level.ERROR, response.getMessage(), fromtodateField); } } }); }
From source file:net.cbtltd.client.widget.book.BookWidget.java
private void getJsonpProductNameIds(String productid) { JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); String url = HOSTS.jsonUrl() + "?service=" + JSONRequest.NAMEID + "&pos=" + pos + "&model=" + NameId.Type.Product.name() + "&id=" + productid; loader.setVisible(true);/*from w w w. jav a 2 s . c o m*/ jsonp.requestObject(url, new AsyncCallback<NameIdWidgetItems>() { @Override public void onFailure(Throwable x) { loader.setVisible(false); throw new RuntimeException(Error.nameid_json.getMessage() + " " + x.getMessage()); } @Override public void onSuccess(NameIdWidgetItems response) { loader.setVisible(false); if (response != null && response.getItems() != null && response.getItems().length() > 0) { ArrayList<NameId> items = new ArrayList<NameId>(); for (int index = 0; index < response.getItems().length(); index++) { items.add(new NameId(response.getItems().get(index).getName(), response.getItems().get(index).getId())); } productField.setItems(items); } } }); }
From source file:net.cbtltd.client.widget.book.BookWidget.java
private void getJsonpReservation(String reservationid) { JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); String url = HOSTS.jsonUrl() + "?service=" + JSONRequest.RESERVATION + "&pos=" + pos + "&id=" + reservationid;//ww w.j av a2s . c om loader.setVisible(true); jsonp.requestObject(url, new AsyncCallback<ReservationWidgetItem>() { @Override public void onFailure(Throwable x) { loader.setVisible(false); throw new RuntimeException(Error.reservation_json.getMessage() + " " + x.getMessage()); } @Override public void onSuccess(ReservationWidgetItem response) { loader.setVisible(false); productField.setValue(response.getProductid()); emailaddressField.setValue(response.getEmailaddress()); firstnameField.setValue(response.getFirstname()); familynameField.setValue(response.getFamilyname()); fromtodateField.setValue(RazorWidget.DF.parse(response.getFromdate())); fromtodateField.setTovalue(RazorWidget.DF.parse(response.getTodate())); amountField.setValue(response.getAmount()); amountField.setUnitvalue(response.getCurrency()); notesField.setValue(response.getMessage()); setPaymentVisible(response.getQuote() > 0.0); confirmationReport.setVisible(false); submitButton.setVisible(true); resetButton.setVisible(true); } }); }
From source file:net.cbtltd.client.widget.book.BookWidget.java
private void getJsonpReservationRS() { if (RazorWidget.ifMessage(fromtodateField.noValue(), Level.ERROR, CONSTANTS.fromdateError(), fromtodateField)/* ww w . jav a 2 s .co m*/ || RazorWidget.ifMessage(fromtodateField.noTovalue(), Level.ERROR, CONSTANTS.todateError(), fromtodateField) || RazorWidget.ifMessage(fromtodateField.isEndBeforeStart(), Level.ERROR, CONSTANTS.endBeforeStartError(), fromtodateField) || RazorWidget.ifMessage(fromtodateField.getDuration(Time.DAY) < 1, Level.ERROR, CONSTANTS.endBeforeStartError(), fromtodateField) || RazorWidget.ifMessage(emailaddressField.noValue(), Level.ERROR, CONSTANTS.emailaddressError(), emailaddressField) || RazorWidget.ifMessage(!Party.isEmailAddress(emailaddressField.getValue()), Level.ERROR, CONSTANTS.emailaddressError(), emailaddressField) || RazorWidget.ifMessage(familynameField.noValue(), Level.ERROR, CONSTANTS.familynameError(), familynameField) || RazorWidget.ifMessage(firstnameField.noValue(), Level.ERROR, CONSTANTS.firstnameError(), firstnameField) || RazorWidget.ifMessage(amountField.noValue() || amountField.getValue() <= 0.0, Level.ERROR, CONSTANTS.amountError(), amountField) || RazorWidget.ifMessage(cardholderField.noValue(), Level.ERROR, CONSTANTS.cardholderError(), cardholderField) || RazorWidget.ifMessage(cardnumberField.noValue(), Level.ERROR, CONSTANTS.cardnumberError(), cardnumberField) || RazorWidget.ifMessage(!Finance.isCreditCardNumber(cardnumberField.getValue()), Level.ERROR, CONSTANTS.cardnumberError(), cardnumberField) || RazorWidget.ifMessage(cardmonthField.noValue(), Level.ERROR, CONSTANTS.cardmonthError(), cardmonthField) || RazorWidget.ifMessage(cardyearField.noValue(), Level.ERROR, CONSTANTS.cardyearError(), cardyearField) || RazorWidget.ifMessage(cardcodeField.noValue() || cardcodeField.getValue().length() != 3, Level.ERROR, CONSTANTS.cardcodeError(), cardcodeField)) { return; } JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); String url = HOSTS.jsonUrl() + "?service=" + JSONRequest.RESERVATION + "&method=set" + "&pos=" + pos + "&reservationid=" + reservationid + "&emailaddress=" + emailaddressField.getValue() + "&familyname=" + familynameField.getValue() + "&firstname=" + firstnameField.getValue() + "&cardholder=" + cardholderField.getValue() + "&cardnumber=" + cardnumberField.getValue() + "&cardmonth=" + cardmonthField.getValue() + "&cardyear=" + cardyearField.getValue() + "&cardcode=" + cardcodeField.getValue() + "&amount=" + amountField.getValue(); loader.setVisible(true); jsonp.requestObject(url, new AsyncCallback<PayWidgetItem>() { @Override public void onFailure(Throwable x) { LoadingPopup.getInstance().hide(); loader.setVisible(false); throw new RuntimeException(Error.reservation_json.getMessage() + " " + x.getMessage()); } @Override public void onSuccess(PayWidgetItem response) { loader.setVisible(false); if (response.hasState(RazorWidget.State.SUCCESS.name())) { StringBuilder sb = new StringBuilder(); sb.append("Payment Reference: " + response.getName()); sb.append("\nAmount: " + response.getAmount() + " " + response.getCurrency()); submitButton.setVisible(false); resetButton.setVisible(true); } else { AbstractField.addMessage(Level.ERROR, response.getMessage(), cardholderField); } } }); }
From source file:net.cbtltd.client.widget.calendar.CalendarWidget.java
private void getJsonpCalendar() { if (productField.noValue() || displayedMonth == null) { return;//from ww w .j a v a2s .c o m } JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); String url = HOSTS.jsonUrl() + "?service=" + JSONRequest.CALENDAR + "&pos=" + pos + "&productid=" + productField.getValue() + "&date=" + RazorWidget.DF.format(getDaysGridOrigin(displayedMonth)); loader.setVisible(true); jsonp.requestObject(url, new AsyncCallback<CalendarWidgetItems>() { @Override public void onFailure(Throwable x) { loader.setVisible(false); throw new RuntimeException(Error.widget_calendar.getMessage() + " " + x.getMessage()); } @Override public void onSuccess(CalendarWidgetItems response) { loader.setVisible(false); renderCalendarWidgetItems(response); } }); }