List of usage examples for org.apache.wicket.request.cycle RequestCycle get
public static RequestCycle get()
From source file:at.molindo.wicketutils.migration.ex.AbstractRestartResponseException.java
License:Apache License
public AbstractRestartResponseException() { RequestCycle rc = RequestCycle.get(); if (rc != null) { rc.getResponse().reset(); } }
From source file:at.molindo.wicketutils.utils.MockUtilsTest.java
License:Apache License
@Test public void withSession() throws Exception { DummyApplication testApp = new DummyApplication(); try {/*from www . j av a2s . c o m*/ assertFalse(Application.exists()); assertFalse(Session.exists()); assertFalse(RequestCycle.get() != null); String stringResource = MockUtils.withRequest(testApp, new MockRequestCallback<String>() { @Override public String call() { // some basic testing assertTrue(Application.exists()); assertFalse(Session.exists()); assertTrue(RequestCycle.get() != null); return new StringResourceModel("someResource", (IModel<?>) null, Model.of("default value")) .getString(); } }); assertEquals("default value", stringResource); String url = MockUtils.withRequest(testApp, new MockRequestCallback<String>() { @Override public String call() { return RequestCycle.get().urlFor(HomePage.class, null).toString(); } }); assertEquals(".", url); Locale locale = MockUtils.withRequest(testApp, new IMockRequestCallback<Locale>() { @Override public void configure(MockRequest request) { request.setLocale(Locale.GERMAN); } @Override public Locale call() { return Session.get().getLocale(); } }); assertEquals(Locale.GERMAN, locale); assertFalse(Application.exists()); assertFalse(Session.exists()); assertFalse(RequestCycle.get() != null); } finally { testApp.destroy(); } }
From source file:at.molindo.wicketutils.utils.PageSpec.java
License:Apache License
public void setAsResponsePage(boolean redirect) { RequestCycle rc = RequestCycle.get(); if (rc == null) { throw new WicketRuntimeException("no request cycle available"); }// w w w . j a v a 2 s . c o m setAsResponsePage(rc, redirect); }
From source file:at.molindo.wicketutils.utils.RequestCycleCache.java
License:Apache License
public static <K, V> void put(final MetaDataKey<Pair<K, V>> metaDataKey, final K key, final V value) { put(RequestCycle.get(), metaDataKey, key, value); }
From source file:at.molindo.wicketutils.utils.RequestCycleCache.java
License:Apache License
public static <K, V> V get(final MetaDataKey<Pair<K, V>> metaDataKey, final K key) { return get(RequestCycle.get(), metaDataKey, key); }
From source file:at.molindo.wicketutils.utils.RequestCycleCache.java
License:Apache License
public static <K, V> V get(final RequestCycle cycle, final MetaDataKey<Pair<K, V>> metaDataKey, final K key) { if (metaDataKey == null) { throw new NullPointerException("metaDataKey"); }/*from w ww . j a v a2 s .c o m*/ if (key == null) { return null; } final Pair<K, V> pair = RequestCycle.get().getMetaData(metaDataKey); return pair == null || !pair.getKey().equals(key) ? null : pair.getValue(); }
From source file:at.molindo.wicketutils.utils.RequestCycleCache.java
License:Apache License
/** * tries to get value for key from cache or invokes function to generate it * from key./*w ww. ja va 2s . co m*/ */ public static <K, V> V getOrCreate(final MetaDataKey<Pair<K, V>> metaDataKey, final K key, Function<K, V> function) { return getOrCreate(RequestCycle.get(), metaDataKey, key, function); }
From source file:at.molindo.wicketutils.utils.RequestCycleCache.java
License:Apache License
public static <K, V> void remove(final MetaDataKey<Pair<K, V>> metaDataKey) { if (metaDataKey != null) { RequestCycle.get().setMetaData(metaDataKey, null); }/*from w w w . j a va2 s . c o m*/ }
From source file:at.molindo.wicketutils.utils.WicketUtils.java
License:Apache License
/** * @return may return null/*w w w . j a v a 2 s . com*/ */ public static Request getRequest() { final RequestCycle rc = RequestCycle.get(); return rc == null ? null : rc.getRequest(); }
From source file:at.molindo.wicketutils.utils.WicketUtils.java
License:Apache License
/** * @deprecated use {@link RequestCycle#get()} */ @Deprecated public static RequestCycle getWebRequestCycle() { return RequestCycle.get(); }