Should be simple enough. Implement
HttpServletRequestListener
and store the current request in a ThreadLocal (calls to onRequestStart aren’t serialized in the same way as business calls to the Application object are). So your application would include:
private static final ThreadLocal<HttpServletRequest> tlRequest =
new ThreadLocal<HttpServletRequest>();
@Override
public void onRequestStart(HttpServletRequest req, HttpServletResponse resp) {
tlRequest.set(req);
}
@Override
public void onRequestEnd(HttpServletRequest req, HttpServletResponse resp) {
tlRequest.remove();
}
Now in your init() method grab the request and call
getRequestURL()
,
getServerName()
, or something similar to get the URL that was used to access the application. Then you can call setTheme() from there to set the correct theme.
Cheers,
Bobby