You probably overcome all the problems already, but just a tip to everyone else testing with the simple cookie lister code: if it appears empty the reason might simply be that there are no cookies set in the browser. Try setting a cookie.
You mean helps on disabling the session serialization and reloads work? For this using the ‘restartApplication’ url parameter is a easier (and “the right”) way.
Ok, that makes sense although if everything works that should not even show. Changed that to the sample code.
Also, I now tested with Vaadin 6.3.3 and uploaded the new add-on version. So visit the Directory for samples/demos/download:
I think the biggest problem was that - I don’t know why (maybe I don’t know Vaadin so well) but - adding components to Panels generates blank page. I deleted panels, put VerticalPanel and HorizontalPanel indead and then I saw DateField for the first time. It should be there always, even when there are no cookies.
As I understand sample code (BrowserCookiesApplication) works for you so I wonder why panels are blank at my Firefox 3.6.3 (latest). There sould be no differences but…
(Now I see that you put ‘online demo’, the date picker (this small calendar) works now, it never shown in my modifed version.)
Hi, Sami! I use this widget, and… How I can save cookies manually? Can you implement this method? I would appreciate:)
Without this method I’m forced use cheats…
I’m sorry, now I don’t quite understand what you are looking for. Do you have already implemented that in some way? A piece of code might help. Thanks!
Hello!
I think that save cookies only on repaint - is no very good idea. In my task, I should save/remove a data (key and value) into cookies without repaint, and I need public methods save and restore cookies. Yes, it is not a bug, but it would convenient? how do you think?
and…
I have exception at cookies.put(cookie[0]
, cookie[1]
); without if(cookie.length >= 2) (with empty cookie value).
this is minor quick fix
Hi! If you mean that the cookie contents is still listed in the demo, this is because the application session is still alive. Try to use the ?restartApplication parameter to reload the application and see what happens.
Hmm… Make sure you have activated the right project in the left pane. Sometimes the plugin does not find the project otherwise.
Well, no really. I mean cookies are readable in the browser and storing clear text passwords there would be easy to read there. However, other websites cannot read the cookies.
The safest way to make sure the plugin recognizes your project is to go in the Project Explorer view or the Package Explorer view and select you .gwt.xml file for your widgetset. The widgetset definition file is referenced by the WEB-INF/web.xml file – the location in web.xml should match your file.
I’m using BrowserCookies v. 1.0.4, and I just noticed that the component doesn’t work for saving cookies unless I put it in my main window. I was trying to put the BrowserCookies component in my sub-window (actually, the login window), and I just can’t save a cookie (I can read them, but can’t add/update).
The problem is solved putting the component in my main window. It is not a big problem, but I think it would be nice to allow sub-windows to make their job without the blessings of the main one.
An other issue (here I go again, 90% of my posts are about that): the add-on is not 100% compatible with Google App Engine. The UpdateListener interface should extends Serializable, to allow clients to create anonymous listeners with no trouble.
For example, today GAE complains about this:
BrowserCookies cookies = new BrowserCookies();
cookies.addListener(new UpdateListener(){ //<-- not serializable!!!
@Override
public void cookiesUpdated(BrowserCookies browserCookies) {}
});
Instead, I have to create my own named class, make it implements UpdateListener and Serializable, and then use it:
private class BoringListener implements UpdateListener, Serializable {
@Override
public void cookiesUpdated(BrowserCookies browserCookies) {}
}
//...
BrowserCookies cookies = new BrowserCookies();
cookies.addListener(new BoringListener());
I’m using BrowserCookies v. 1.0.4, and I just noticed that the component doesn’t work for saving cookies unless I put it in my main window. I was trying to put the BrowserCookies component in my sub-window (actually, the login window), and I just can’t save a cookie (I can read them, but can’t add/update).
The problem is solved putting the component in my main window. It is not a big problem, but I think it would be nice to allow sub-windows to make their job without the blessings of the main one.
An other issue (here I go again, 90% of my posts are about that =P): the add-on is not 100% compatible with Google App Engine. The UpdateListener interface should extends Serializable, to allow clients to create anonymous listeners with no trouble.
For example, today GAE complains about this:
BrowserCookies cookies = new BrowserCookies();
cookies.addListener(new UpdateListener(){ //<-- not serializable!!!
@Override
public void cookiesUpdated(BrowserCookies browserCookies) {}
});
Instead, I have to create my own named class, make it implements UpdateListener and Serializable, and then use it:
private class SerializableUpdateListener implements UpdateListener, Serializable {
@Override
public void cookiesUpdated(BrowserCookies browserCookies) {}
}
//...
BrowserCookies cookies = new BrowserCookies();
cookies.addListener(new SerializableUpdateListener());
Again, not a big problem, just an improvement that can be done.
Hmm. Actually, I cannot think why it does not work in subwindow as long as it added to the component hierarchy.
Overall, it is a little bit counterintuitive that components like this are added at all, but that is just how Vaadin works.
Right. This is a valid complaint It should be an easy fix, and I try to find the time slot to fix that.
Hi, i’m using the addon to save the user’s fav locale.
It works good but, if i wanna use the setCookie method with the domain and path as params, it just won’t save the cookie.
I’m using Chrome on mac, and for localhost i do the following:
I tried all the combinations for localhost and the path, but it just won’t be saved on browser.
The browser address for my local deploy is http://localhost:8080/AppName
Hi, i’m using the addon to save the user’s fav locale.
It works good but, if i wanna use the setCookie method with the domain and path as params, it just won’t save the cookie.
I’m using Chrome on mac, and for localhost i do the following:
I tried all the combinations for localhost and the path, but it just won’t be saved on browser.
The browser address for my local deploy is http://localhost:8080/AppName
public class Application extends com.vaadin.Application implements
HttpServletRequestListener {
private BrowserCookies cookies;
public void init() {
setTheme("parus");
cookies = new BrowserCookies();
...
}
public BrowserCookies getCookies() {
return cookies;
}
CookieUtil
public class CookieUtil {
/**
* Добавить кукис
* Значение куки кодируется в Base64
* @param name имя
* @param value значение
*/
public static void addCookie(String name, String value) {
if (value != null && !value.isEmpty()) {
Date date = DateUtil.shiftDate(DateUtil.getCurDate(), Calendar.HOUR, 24*7);
//int saveCookiesTime = 7 * 24 * 60 * 60; //7 дней
Application.getInstance()
.getCookies().setCookie(name, CryptUtil.strToBase64(value, true), date);
}
}
/**
* Получить кукис
* Значение декодируется из Base64
* @param name
* @return значение кукиса или null
*/
public static String getCookie(String name) {
String value = Application.getInstance().getCookies().getCookie(name);
if (value != null) {
value = CryptUtil.base64ToStr(value, true);
}
return value;
}
}
After user authorization i try add cookies. But the cookies did not appear.