The offer concerning a method in the WebBrowser

Hi, All!

Dear Vaadin team!

The first question, to be exact, the first offer with which I would like to begin discussion it is about a component WebBrowser. It does not return a user time zone. Does it possible to implement this method?
We with colleagues have thought that for you it will be simple, because in a JavaScript it becomes in one line.

Thanks!
best regards

P.S.
I 'm sorry for my English and I ask you not to kick strongly for probably silly questions, please.
many thanks! :*)

Hi,

You can get Locale from HttpServletRequest and the Locale contains time zone information, maybe that’s suitable for your needs. Hopefully the following simple application helps you:



@SuppressWarnings("serial")
public class TestApplication extends Application implements
		HttpServletRequestListener {

	@Override
	public void init() {
		Window mainWindow = new Window("");
		setMainWindow(mainWindow);
	}

	public void onRequestStart(HttpServletRequest request,
			HttpServletResponse response) {
		Locale l = request.getLocale();
		Calendar calendar = Calendar.getInstance(l);
		TimeZone timeZone = calendar.getTimeZone();
		System.out.println(timeZone.getDisplayName());
	}

	public void onRequestEnd(HttpServletRequest request,
			HttpServletResponse response) {
	}
}

-Henri

Hi Henri,
Thanks for the answer and helpful information!

Best regards

Hi Henri,

It was found out that this method doesn’t meet our requirements, and it won’t work in practice how it would be desirable.
Locale does not contain time zone information.
Formally, the method Calendar.getInstance(Locale) “Gets a calendar using the DEFAULT time zone and specified locale.” as it is said in javadoc.
Actually, how can you imagine the possibility to get one of eleven possible timezones from one Locale(“ru-RU”)?

But with the aid of JavaScript code running in the browser you could easily get the timezone information from the users computer, from the Date object for example. Therefore our offer apropos the Vaadin component WebBrowser remains in force.

Best regards

Hi,

Sorry for misleading you with the HttpServletRequest locale.

You can create
an enhancement ticket
about adding locale information to WebBrowser. Or you can create your own widget that gets time zone information from the web browser and transfers it to the server.