문제

What is the best way of saving preferences on client side (eg. language choice) for a JSF WebApp? I would like the data to persist the closing of the browser. Per requirement I can't use the browser locale to detect the preferred language.

I was hoping for something like a BrowserScoped bean. Should I try using a CustomScoped bean (I've never used them before) or should I use plain old JavaScript?

Thanks!

도움이 되었습니까?

해결책

Sounds like you're looking for long living Cookies to me.

You should take a look at ExternalContext.addResponseCookie() to store your cookie and HttpServletRequest.getCookies() to retrieve it.
Although it's not the same use case as yours I would like to refer you to this BalusC answer if you want grant your cookies a long life.

다른 팁

I recommend an approach involving JavaScript DOM Storage. You can tie it to a session if necessary. It boils down to a map of properties at its core, that is accessible from your app's domain.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top