Hi,
Thank you for the hint. Do you have an idea where should place my code? I tried 
it in the constructor of my index webpage, but the setLocale method created a 
page reload that did not occur in the Webapplication constructor.

Thanks,
Andre

---
Andre Schütz
www.faustas.de

Dan Retzlaff <[email protected]> schrieb:

>Andre, check out this javadoc comment on Session#getClientInfo:
>
> * Note: Do <strong>not</strong> call this method from your custom {@link
>Session} constructor
> * because the temporary page needs a constructed {@link Session} to be
>able to work.
>
>Dan
>
>2012/3/13 "André Schütz" <[email protected]>
>
>> Hi,
>>
>> I have the following code in my MyApplication class:
>>
>> {CODE}
>>
>> public void init() {
>>    super.init();
>>    getRequestCycleSettings().setGatherExtendedBrowserInfo(true);
>>    getResourceSettings().setThrowExceptionOnMissingResource(false);
>>
>>    ...
>> }
>>
>> public Session newSession(Request request, Response response) {
>>        MySession session = new MySession(request);
>>
>>        // determine default language from the browser
>>        String defaultLanguage = null;
>>        if (request != null && request.getClientUrl() != null &&
>> !request.getClientUrl().toString().isEmpty()) {
>>            defaultLanguage =
>> session.getClientInfo().getProperties().getNavigatorLanguage();
>>        }
>>        Locale locale = session.getLocale();
>>
>>        // no locale available
>>        if (locale == null) {
>>            if (defaultLanguage != null) {
>>                if (defaultLanguage.startsWith("en")) {
>>                    locale = new Locale("en", "EN");
>>                }
>>                else if (defaultLanguage.startsWith("de")) {
>>                    locale = new Locale("de", "DE");
>>                }
>>            }
>>            else {
>>                locale = new Locale("en", "EN");
>>            }
>>
>>            session.setLocale(locale);
>>        }
>>
>>        return session;
>>    }
>>
>> {CODE}
>>
>> I get an error, when I delete the Cookies in my browser and reload the
>> actual page. The same error occurs when I delete the line ( if (request !=
>> null && request.getClientUrl() != null &&
>> request.getClientUrl().toString().isEmpty()) { ) from the code example at
>> building time from the TestHomePage.java.
>>
>> The error is:
>>
>> {ERROR}
>>
>> java.lang.StackOverflowError
>>
>>  
>> org.apache.wicket.session.HttpSessionStore.getHttpSession(HttpSessionStore.java:95)
>>
>>  
>> org.apache.wicket.session.HttpSessionStore.getSessionId(HttpSessionStore.java:155)
>>
>>  org.apache.wicket.session.HttpSessionStore.lookup(HttpSessionStore.java:192)
>>
>>  
>> org.apache.wicket.Application.fetchCreateAndSetSession(Application.java:1526)
>>        org.apache.wicket.Session.get(Session.java:156)
>>
>>  org.apache.wicket.Application$1.onInstantiation(Application.java:279)
>>
>>  
>> org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:36)
>>
>>  
>> org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:34)
>>
>>  
>> org.apache.wicket.util.listener.ListenerCollection.notify(ListenerCollection.java:80)
>>
>>  
>> org.apache.wicket.application.ComponentInstantiationListenerCollection.onInstantiation(ComponentInstantiationListenerCollection.java:32)
>>        org.apache.wicket.Component.<init>(Component.java:678)
>>        org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:118)
>>        org.apache.wicket.Page.<init>(Page.java:206)
>>        org.apache.wicket.Page.<init>(Page.java:170)
>>        org.apache.wicket.markup.html.WebPage.<init>(WebPage.java:74)
>>
>>  
>> org.apache.wicket.markup.html.pages.BrowserInfoPage.<init>(BrowserInfoPage.java:66)
>>
>>  
>> org.apache.wicket.protocol.http.WebSession.newBrowserInfoPage(WebSession.java:239)
>>
>>  
>> org.apache.wicket.protocol.http.WebSession.getClientInfo(WebSession.java:216)
>>
>> {ERROR}
>>
>> Any ideas why that happens?
>>
>> Thank you,
>> Andre
>> --
>> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
>> belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>

Reply via email to