List of usage examples for com.google.gwt.core.client JsonUtils safeEval
public static native <T extends JavaScriptObject> T safeEval(String json) ;
From source file:com.google.web.bindery.autobean.shared.impl.StringQuoter.java
License:Apache License
public static Splittable split(String payload) { char c = payload.charAt(0); boolean isSimple = c != '{' && c != '['; if (isSimple) { payload = "[" + payload + "]"; }/* w w w .ja va 2 s . c o m*/ Splittable toReturn = JsonUtils.safeEval(payload).<JsoSplittable>cast(); if (isSimple) { toReturn = toReturn.get(0); } return toReturn; }
From source file:com.tdm.client.dispatch.handler.GetCurrentConsensusHandler.java
License:Apache License
@Override protected GetCurrentConsensusResult extractResult(final Response response) { CurrentConsensusJSO consensus = JsonUtils.safeEval(response.getText()); return new GetCurrentConsensusResult(consensus); }
From source file:com.tdm.client.dispatch.handler.GetExpertListHandler.java
License:Apache License
@Override protected GetExpertListResult extractResult(final Response response) { JsArray<ExpertJso> res = JsonUtils.safeEval(response.getText()); return new GetExpertListResult(res); }
From source file:com.tdm.client.dispatch.handler.GetProblemByIdHandler.java
License:Apache License
@Override protected GetProblemByIdResult extractResult(final Response response) { ProblemJSO problem = JsonUtils.safeEval(response.getText()); return new GetProblemByIdResult(problem); }
From source file:com.tdm.client.dispatch.handler.GetProblemListHandler.java
License:Apache License
@Override protected GetProblemListResult extractResult(final Response response) { JsArray<ProblemJSO> problems = JsonUtils.safeEval(response.getText()); return new GetProblemListResult(problems); }
From source file:com.tdm.client.dispatch.handler.GetSolutionIdeaListHandler.java
License:Apache License
@Override protected GetSolutionIdeaListResult extractResult(final Response response) { JsArray<SolutionIdeaJSO> res = JsonUtils.safeEval(response.getText()); return new GetSolutionIdeaListResult(res); }
From source file:elemental.json.impl.JreJsonValue.java
License:Apache License
@Override public Object toNative() { // use browser JS parser, returns JSO return JsonUtils.safeEval(((JsonValue) this).toJson()); }
From source file:fr.gael.dhus.gwt.client.page.CartPage.java
License:Open Source License
private static void getCart(final int start, final int length, final JavaScriptObject function) { DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "wait"); GWTClient.callback(function,/*from ww w .j a va 2 s .c o m*/ JsonUtils.safeEval("{\"aaData\": [],\"iTotalRecords\" : 0, \"iTotalDisplayRecords\" : 0}")); final UserData user = GWTClient.getCurrentUser(); productCartService.countProductsInCart(user.getId(), new AccessDeniedRedirectionCallback<Integer>() { @Override public void _onFailure(Throwable caught) { DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "default"); Window.alert("There was an error while counting products in your cart."); } @Override public void onSuccess(final Integer total) { productCartService.getProductsOfCart(start, length, user.getId(), new AccessDeniedRedirectionCallback<List<ProductData>>() { @Override public void _onFailure(Throwable caught) { DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "default"); Window.alert("There was an error while accessing to your cart."); } @Override public void onSuccess(final List<ProductData> products) { String json = toJson(GWT.getHostPageBaseURL(), products, GWTClient.getCurrentUser(), total); clear.getElement() .setClassName(products.size() >= 1 ? "button_black" : "button_disabled"); download.getElement() .setClassName(products.size() >= 1 ? "button_black" : "button_disabled"); GWTClient.callback(function, JsonUtils.safeEval(json)); DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "default"); } }); } }); }
From source file:fr.gael.dhus.gwt.client.page.management.ManagementCollectionsPage.java
License:Open Source License
private static void getCollections(final JavaScriptObject function) { DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "wait"); GWTClient.callback(function,/* ww w. j a v a 2s.c om*/ JsonUtils.safeEval("{\"aaData\": [],\"iTotalRecords\" : 0, \"iTotalDisplayRecords\" : 0}")); if (root == null) { root = new CollectionData(); root.setId(null); root.setDeep(-1); } toRefresh = new ArrayList<Long>(); for (CollectionData c : displayedCollections.values()) { if (c.getDisplayedChildren() != null && c.getDisplayedChildren().size() > 0) { toRefresh.add(c.getId()); } } displayedCollections.clear(); requestCollections(root, new AccessDeniedRedirectionCallback<Void>() { @Override public void _onFailure(Throwable caught) { DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "default"); } @Override public void onSuccess(Void result) { String json = "{\"aaData\": ["; json += computeJSON(root); boolean children = false; if (root.getDisplayedChildren() != null && root.getDisplayedChildren().size() > 0) { json = json.substring(0, json.length() - 1); children = true; } json += "],\"iTotalRecords\" : " + (children ? 1 : 0) + ", \"iTotalDisplayRecords\" : " + (children ? 1 : 0) + "}"; GWTClient.callback(function, JsonUtils.safeEval(json)); DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "default"); } }); }
From source file:fr.gael.dhus.gwt.client.page.management.ManagementCollectionsPage.java
License:Open Source License
private static void getProducts(final int start, final int length, final String search, final JavaScriptObject function) { DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "wait"); final Long parentId = selectedCollection != null && selectedCollection.getParent() != null ? selectedCollection.getParent().getId() : null;// ww w. j av a2s.c o m GWTClient.callback(function, JsonUtils.safeEval("{\"aaData\": [],\"iTotalRecords\" : 0, \"iTotalDisplayRecords\" : 0}")); productService.count(search, parentId, new AccessDeniedRedirectionCallback<Integer>() { @Override public void _onFailure(Throwable caught) { DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "default"); Window.alert("There was an error while counting products"); } @Override public void onSuccess(final Integer total) { //selectedCollection.getParent ().getId () productService.getProducts(start, length, search, parentId, new AccessDeniedRedirectionCallback<List<ProductData>>() { @Override public void _onFailure(Throwable caught) { DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "default"); Window.alert("There was an error while searching for '" + search + "'"); } @Override public void onSuccess(List<ProductData> products) { displayedProducts = products; boolean allChecked = true; String json = "{\"aaData\": ["; for (ProductData product : products) { boolean checked = (selectedCollection != null && selectedCollection.contains(product.getId())); allChecked = allChecked && checked; json += "[{\"checked\":" + checked + ", \"id\":\"" + product.getId() + "\" }, \"" + product.getIdentifier() + "\"],"; } if (total > 0) { json = json.substring(0, json.length() - 1); } else { allChecked = false; productsCheckAllDisabled = true; } json += "],\"iTotalRecords\" : " + total + ", \"iTotalDisplayRecords\" : " + total + "}"; GWTClient.callback(function, JsonUtils.safeEval(json)); DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "default"); productsCheckAll = SimpleCheckBox .wrap(RootPanel.get("productsCheckAll").getElement()); productsCheckAll.setValue(allChecked); productsCheckAll.setEnabled(!productsCheckAllDisabled && (state == State.EDIT || state == State.CREATE || state == State.CREATESUB)); } }); } }); }