List of usage examples for com.google.gwt.user.client Cookies getCookie
public static String getCookie(String name)
From source file:com.extjs.gxt.ui.client.state.CookieProvider.java
License:sencha.com license
protected String getValue(String name) { return Cookies.getCookie(name); }
From source file:com.fredhat.gwt.xmlrpc.client.XmlRpcRequest.java
License:Open Source License
/** * Invokes the XML-RPC method asynchronously. All success and failure logic will * be in your {@link AsyncCallback} that you defined in the constructor. */// ww w.j a v a2 s . c om public void execute() { if (methodName == null || methodName.equals("")) { callback.onFailure(new XmlRpcException("The method name parameter cannot be null")); return; } if (params == null) params = new Object[] {}; Document request = buildRequest(methodName, params); if (client.getDebugMode()) System.out.println("** Request **\n" + request + "\n*************"); RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST, client.getServerURL()); requestBuilder.setHeader("Content-Type", "text/xml"); //Ak existuje cookie posli ju v hlavicke if (Cookies.getCookie("sessionID") != null) { requestBuilder.setHeader("sessionID", Cookies.getCookie("sessionID")); } requestBuilder.setTimeoutMillis(client.getTimeoutMillis()); if (client.getUsername() != null) requestBuilder.setUser(client.getUsername()); if (client.getPassword() != null) requestBuilder.setPassword(client.getPassword()); try { requestBuilder.sendRequest(request.toString(), new RequestCallback() { public void onResponseReceived(Request req, Response res) { if (res.getStatusCode() != 200) { callback.onFailure(new XmlRpcException("Server returned " + "response code " + res.getStatusCode() + " - " + res.getStatusText())); return; } try { T responseObj = buildResponse(res.getText()); callback.onSuccess(responseObj); } catch (XmlRpcException e) { callback.onFailure(e); } catch (ClassCastException e) { callback.onFailure(e); } } public void onError(Request req, Throwable t) { callback.onFailure(t); } }); } catch (RequestException e) { callback.onFailure(new XmlRpcException("Couldn't make server request. Are you violating the " + "Same Origin Policy? Error: " + e.getMessage(), e)); } }
From source file:com.fullmetalgalaxy.client.game.GameEngine.java
License:Open Source License
private void restoreHMIFlags() { applyHMIFlags(Cookies.getCookie("HMIFlags")); }
From source file:com.google.gerrit.client.auth.openid.OpenIdSignInDialog.java
License:Apache License
private void createIdentBox() { boolean remember = mode == SignInMode.SIGN_IN || mode == SignInMode.REGISTER; final FlowPanel group = new FlowPanel(); group.setStyleName(OpenIdResources.I.css().loginLine()); final FlowPanel line1 = new FlowPanel(); group.add(line1);//from w ww . ja v a 2 s. c om providerId = new NpTextBox(); providerId.setVisibleLength(60); providerId.setStyleName(OpenIdResources.I.css().identifier()); providerId.setTabIndex(0); providerId.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(final KeyPressEvent event) { if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) { event.preventDefault(); form.submit(); } } }); line1.add(providerId); login = new Button(); switch (mode) { case LINK_IDENTIY: login.setText(OpenIdUtil.C.buttonLinkId()); break; case REGISTER: login.setText(OpenIdUtil.C.buttonRegister()); break; case SIGN_IN: default: login.setText(OpenIdUtil.C.buttonSignIn()); break; } login.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { form.submit(); } }); login.setTabIndex(remember ? 2 : 1); line1.add(login); Button close = new Button(Gerrit.C.signInDialogClose()); close.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); close.setTabIndex(remember ? 3 : 2); line1.add(close); if (remember) { rememberId = new CheckBox(OpenIdUtil.C.rememberMe()); rememberId.setTabIndex(1); group.add(rememberId); String last = Cookies.getCookie(OpenIdUrls.LASTID_COOKIE); if (last != null && !"".equals(last)) { if (last.startsWith("\"") && last.endsWith("\"")) { // Dequote the value. We shouldn't have to do this, but // something is causing some Google Account tokens to get // wrapped up in double quotes when obtained from the cookie. // last = last.substring(1, last.length() - 2); } providerId.setText(last); rememberId.setValue(true); } } formBody.add(group); }
From source file:com.google.gerrit.client.change.NewChangeScreenBar.java
License:Apache License
static boolean show() { if (Gerrit.isSignedIn()) { return Gerrit.getUserAccount().getGeneralPreferences().getChangeScreen() == null; }//from w ww. j a v a 2 s . c om return Cookies.getCookie(Dispatcher.COOKIE_CS2) == null; }
From source file:com.google.gerrit.client.MessageOfTheDayBar.java
License:Apache License
private static List<HostPageData.Message> filter(List<HostPageData.Message> in) { List<HostPageData.Message> show = new ArrayList<>(); for (HostPageData.Message m : in) { if (Cookies.getCookie(cookieName(m)) == null) { show.add(m);// ww w . j a va2 s .co m } } return show; }
From source file:com.google.gwt.sample.dynatablemvp.client.BrowserManager.java
@Override public String getCookie(String name) { return Cookies.getCookie(name); }
From source file:com.google.gwt.sample.dynatablerf.client.FavoritesManager.java
License:Apache License
public FavoritesManager(final RequestFactory requestFactory) { String cookie = Cookies.getCookie(COOKIE_NAME); if (cookie != null) { try {/*w w w.j a va 2s .c om*/ for (String fragment : cookie.split(",")) { if (fragment.length() == 0) { continue; } EntityProxyId<PersonProxy> id = requestFactory.getProxyId(fragment); if (id != null) { favoriteIds.add(id); } } } catch (NumberFormatException e) { // Not a big deal, start up without favorites favoriteIds.clear(); } } Window.addWindowClosingHandler(new ClosingHandler() { public void onWindowClosing(ClosingEvent event) { StringBuilder sb = new StringBuilder(); for (EntityProxyId<PersonProxy> id : favoriteIds) { sb.append(requestFactory.getHistoryToken(id)).append(","); } Cookies.setCookie(COOKIE_NAME, sb.toString()); } }); }
From source file:com.google.gwt.sample.feedreader.client.Configuration.java
License:Apache License
public Configuration() { String cookieData = Cookies.getCookie(COOKIE_NAME); if (cookieData != null) { try {/*from ww w . jav a 2 s .c o m*/ container.setJSONData(cookieData); } catch (JSONWrapperException e) { // Probably could not parse the json data, revert to builtins initialize(); } } else { initialize(); } }
From source file:com.google.gwt.sample.feedreader.client.Configuration.java
License:Apache License
/** * Save the configuration into the application's cookie. *//*from www . j a v a2 s . co m*/ public void save() { Cookies.setCookie(COOKIE_NAME, container.toString(), new Date(System.currentTimeMillis() + 1000L * 60 * 60 * 24 * 365), null, null, false); System.out.println(Cookies.getCookie(COOKIE_NAME)); }