Search in sources :

Example 1 with WebSession

use of org.apache.wicket.protocol.http.WebSession in project wicket by apache.

the class DynamicJQueryResourceReference method getName.

@Override
public String getName() {
    RequestCycle requestCycle = RequestCycle.get();
    String name = requestCycle.getMetaData(KEY);
    if (name == null) {
        WebClientInfo clientInfo;
        name = getVersion2();
        if (Session.exists()) {
            WebSession session = WebSession.get();
            clientInfo = session.getClientInfo();
        } else {
            clientInfo = new WebClientInfo(requestCycle);
        }
        ClientProperties clientProperties = clientInfo.getProperties();
        if (clientProperties.isBrowserInternetExplorer() && clientProperties.getBrowserVersionMajor() < 9) {
            name = getVersion1();
        }
        requestCycle.setMetaData(KEY, name);
    }
    return name;
}
Also used : WebClientInfo(org.apache.wicket.protocol.http.request.WebClientInfo) ClientProperties(org.apache.wicket.protocol.http.ClientProperties) WebSession(org.apache.wicket.protocol.http.WebSession) RequestCycle(org.apache.wicket.request.cycle.RequestCycle)

Example 2 with WebSession

use of org.apache.wicket.protocol.http.WebSession in project wicket by apache.

the class FormInputApplication method newSession.

@Override
public Session newSession(Request request, Response response) {
    WebSession session = new WebSession(request);
    Locale locale = session.getLocale();
    if (!LOCALES.contains(locale)) {
        session.setLocale(Locale.ENGLISH);
    }
    return session;
}
Also used : Locale(java.util.Locale) WebSession(org.apache.wicket.protocol.http.WebSession)

Example 3 with WebSession

use of org.apache.wicket.protocol.http.WebSession in project wicket by apache.

the class AjaxBehaviorEnabledTest method before.

/**
 */
@Before
public void before() {
    final IAuthorizationStrategy strategy = new CustomStrategy();
    tester = new WicketTester(new MockApplication() {

        @Override
        public Session newSession(Request request, Response response) {
            return new WebSession(request) {

                private static final long serialVersionUID = 1L;

                @Override
                public IAuthorizationStrategy getAuthorizationStrategy() {
                    return strategy;
                }
            };
        }
    });
}
Also used : Response(org.apache.wicket.request.Response) WebSession(org.apache.wicket.protocol.http.WebSession) MockApplication(org.apache.wicket.mock.MockApplication) Request(org.apache.wicket.request.Request) WicketTester(org.apache.wicket.util.tester.WicketTester) IAuthorizationStrategy(org.apache.wicket.authorization.IAuthorizationStrategy) Before(org.junit.Before)

Example 4 with WebSession

use of org.apache.wicket.protocol.http.WebSession in project wicket by apache.

the class AbstractInjectorTest method before.

@Before
public void before() {
    app.setServletContext(new MockServletContext(app, null));
    ThreadContext.setApplication(app);
    app.setName(getClass().getName());
    app.initApplication();
    Session session = new WebSession(new MockWebRequest(Url.parse("/")));
    app.getSessionStore().bind(null, session);
    ThreadContext.setSession(session);
    GuiceComponentInjector injector = new GuiceComponentInjector(app, new Module() {

        @Override
        public void configure(final Binder binder) {
            binder.bind(ITestService.class).to(TestService.class);
            binder.bind(ITestService.class).annotatedWith(Red.class).to(TestServiceRed.class);
            binder.bind(ITestService.class).annotatedWith(Blue.class).to(TestServiceBlue.class);
            binder.bind(new TypeLiteral<Map<String, String>>() {
            }).toProvider(new Provider<Map<String, String>>() {

                @Override
                public Map<String, String> get() {
                    Map<String, String> strings = new HashMap<>();
                    strings.put(ITestService.RESULT, ITestService.RESULT);
                    return strings;
                }
            });
            binder.bind(String.class).annotatedWith(Names.named("named1")).toInstance("NAMED_1");
            binder.bind(String.class).annotatedWith(Names.named("named2")).toInstance("NAMED_2");
            binder.bind(String.class).annotatedWith(new Jsr330Named("named1")).toInstance("NAMED_1");
            binder.bind(String.class).annotatedWith(new Jsr330Named("named2")).toInstance("NAMED_2");
            binder.bind(EvilTestService.class).toInstance(new EvilTestService("evil123", 5));
        }
    });
    app.getComponentInstantiationListeners().add(injector);
}
Also used : HashMap(java.util.HashMap) MockServletContext(org.apache.wicket.protocol.http.mock.MockServletContext) Provider(com.google.inject.Provider) Binder(com.google.inject.Binder) WebSession(org.apache.wicket.protocol.http.WebSession) MockWebRequest(org.apache.wicket.mock.MockWebRequest) Module(com.google.inject.Module) HashMap(java.util.HashMap) Map(java.util.Map) WebSession(org.apache.wicket.protocol.http.WebSession) Session(org.apache.wicket.Session) Before(org.junit.Before)

Example 5 with WebSession

use of org.apache.wicket.protocol.http.WebSession in project webanno by webanno.

the class ApplicationPageBase method isBrowserWarningVisible.

private boolean isBrowserWarningVisible(Properties settings) {
    RequestCycle requestCycle = RequestCycle.get();
    WebClientInfo clientInfo;
    if (Session.exists()) {
        WebSession session = WebSession.get();
        clientInfo = session.getClientInfo();
    } else {
        clientInfo = new WebClientInfo(requestCycle);
    }
    ClientProperties clientProperties = clientInfo.getProperties();
    boolean isUsingUnsupportedBrowser = !clientProperties.isBrowserSafari() && !clientProperties.isBrowserChrome();
    boolean ignoreWarning = "false".equalsIgnoreCase(settings.getProperty(SettingsUtil.CFG_WARNINGS_UNSUPPORTED_BROWSER));
    return isUsingUnsupportedBrowser && !ignoreWarning;
}
Also used : WebClientInfo(org.apache.wicket.protocol.http.request.WebClientInfo) ClientProperties(org.apache.wicket.protocol.http.ClientProperties) WebSession(org.apache.wicket.protocol.http.WebSession) RequestCycle(org.apache.wicket.request.cycle.RequestCycle)

Aggregations

WebSession (org.apache.wicket.protocol.http.WebSession)6 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)3 ClientProperties (org.apache.wicket.protocol.http.ClientProperties)2 WebClientInfo (org.apache.wicket.protocol.http.request.WebClientInfo)2 Before (org.junit.Before)2 Binder (com.google.inject.Binder)1 Module (com.google.inject.Module)1 Provider (com.google.inject.Provider)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 Map (java.util.Map)1 IApplication (org.apache.openmeetings.IApplication)1 IWebSession (org.apache.openmeetings.IWebSession)1 Application (org.apache.wicket.Application)1 Session (org.apache.wicket.Session)1 IAuthorizationStrategy (org.apache.wicket.authorization.IAuthorizationStrategy)1 MockApplication (org.apache.wicket.mock.MockApplication)1 MockWebRequest (org.apache.wicket.mock.MockWebRequest)1 MockWebResponse (org.apache.wicket.mock.MockWebResponse)1 WebApplication (org.apache.wicket.protocol.http.WebApplication)1