org.apache.wicket.request.cycle.IRequestCycleListener Java Examples
The following examples show how to use
org.apache.wicket.request.cycle.IRequestCycleListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestInstall.java From openmeetings with Apache License 2.0 | 6 votes |
@BeforeEach public void setUp() throws Exception { log.info("Going to perform setup for TestInstall"); AbstractSpringTest.setOmHome(); setWicketApplicationName(DEFAULT_APP_NAME); tempFolder = Files.createTempDirectory("omtempdb").toFile(); setH2Home(tempFolder); tester = getWicketTester((Application)ensureApplication(-1L)); RequestCycleListenerCollection listeners = tester.getApplication().getRequestCycleListeners(); for (Iterator<IRequestCycleListener> iter = listeners.iterator(); iter.hasNext();) { IRequestCycleListener l = iter.next(); if (l instanceof WebSocketAwareCsrfPreventionRequestCycleListener) { listeners.remove(l); break; } } assertNotNull(WebSession.get(), "Web session should not be null"); Locale[] locales = Locale.getAvailableLocales(); tester.getSession().setLocale(locales[rnd.nextInt(locales.length)]); log.info("Setup complete"); }
Example #2
Source File: LambdaModel.java From webanno with Apache License 2.0 | 5 votes |
@Override protected void onAttach() { if (autoDetach) { RequestCycle.get().getListeners().add(new IRequestCycleListener() { @Override public void onDetach(RequestCycle aCycle) { LambdaModel.this.detach(); } }); } }
Example #3
Source File: RecommendationServiceImpl.java From inception with Apache License 2.0 | 4 votes |
@EventListener public void onAfterCasWritten(AfterCasWrittenEvent aEvent) { RequestCycle requestCycle = RequestCycle.get(); if (requestCycle == null) { return; } Set<RecommendationStateKey> committed = requestCycle.getMetaData(COMMITTED); if (committed == null) { committed = new HashSet<>(); requestCycle.setMetaData(COMMITTED, committed); } committed.add(new RecommendationStateKey(aEvent.getDocument().getUser(), aEvent.getDocument().getProject())); boolean containsTrainingTrigger = false; for (IRequestCycleListener listener : requestCycle.getListeners()) { if (listener instanceof TriggerTrainingTaskListener) { containsTrainingTrigger = true; } } if (!containsTrainingTrigger) { // Hack to figure out which annotations the user is viewing. This obviously works only // if the user is viewing annotations through an AnnotationPageBase ... still not a // bad guess IPageRequestHandler handler = PageRequestHandlerTracker .getLastHandler(requestCycle); Page page = (Page) handler.getPage(); if (page instanceof AnnotationPageBase) { AnnotatorState state = ((AnnotationPageBase) page).getModelObject(); requestCycle.getListeners() .add(new TriggerTrainingTaskListener(state.getDocument())); } else { // Otherwise use the document from the event... mind that if there are multiple // events, we consider only the first one since after that the trigger listener // will be in the cycle and we do not add another one. // FIXME: This works as long as the user is working on a single document, but not if // the user is doing a bulk operation. If a bulk-operation is done, we get multiple // AfterCasWrittenEvent and we do not know which of them belongs to the document // which the user is currently viewing. requestCycle.getListeners() .add(new TriggerTrainingTaskListener(aEvent.getDocument().getDocument())); } } }