org.apache.wicket.request.cycle.AbstractRequestCycleListener Java Examples

The following examples show how to use org.apache.wicket.request.cycle.AbstractRequestCycleListener. 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: AcademicSessionAdminApplication.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
protected void init() {
	
	//Configure for Spring injection
    getComponentInstantiationListeners().add(new SpringComponentInjector(this));
	
	
	//Don't throw an exception if we are missing a property, just fallback
	getResourceSettings().setThrowExceptionOnMissingResource(false);
	
	//Remove the wicket specific tags from the generated markup
	getMarkupSettings().setStripWicketTags(true);
			
	// On Wicket session timeout, redirect to main page
	getApplicationSettings().setPageExpiredErrorPage(getHomePage());
	getApplicationSettings().setAccessDeniedPage(getHomePage());
	

	
	getRequestCycleListeners().add(new AbstractRequestCycleListener() {
		@Override
		 public IRequestHandler onException(RequestCycle cycle, Exception ex) {
			 if (ex instanceof RuntimeException) {
				 RuntimeException re = (RuntimeException)ex;
				 throw re;
			 }
			 return super.onException(cycle, ex);
		}
	});
	
}
 
Example #2
Source File: AcademicSessionAdminApplication.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
protected void init() {
	
	//Configure for Spring injection
    getComponentInstantiationListeners().add(new SpringComponentInjector(this));
	
	
	//Don't throw an exception if we are missing a property, just fallback
	getResourceSettings().setThrowExceptionOnMissingResource(false);
	
	//Remove the wicket specific tags from the generated markup
	getMarkupSettings().setStripWicketTags(true);
			
	// On Wicket session timeout, redirect to main page
	getApplicationSettings().setPageExpiredErrorPage(getHomePage());
	getApplicationSettings().setAccessDeniedPage(getHomePage());
	

	
	getRequestCycleListeners().add(new AbstractRequestCycleListener() {
		@Override
		 public IRequestHandler onException(RequestCycle cycle, Exception ex) {
			 if (ex instanceof RuntimeException) {
				 RuntimeException re = (RuntimeException)ex;
				 throw re;
			 }
			 return super.onException(cycle, ex);
		}
	});
	
}
 
Example #3
Source File: SiteStatsApplication.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
protected void init() {
	super.init();

	// Configure general wicket application settings
	getComponentInstantiationListeners().add(new SpringComponentInjector(this));
	getResourceSettings().setThrowExceptionOnMissingResource(false);
	getMarkupSettings().setStripWicketTags(true);
	getResourceSettings().getStringResourceLoaders().add(new SiteStatsStringResourceLoader());
	getResourceSettings().getResourceFinders().add(new WebApplicationPath(getServletContext(), "html"));
	getResourceSettings().setResourceStreamLocator(new SiteStatsResourceStreamLocator());
	getDebugSettings().setAjaxDebugModeEnabled(debug);

	// configure bottom page script loading
	setHeaderResponseDecorator(new JavaScriptToBucketResponseDecorator("bottom-script-container"));

	// Mount pages
	mountPage("/home", OverviewPage.class);
	mountPage("/reports", ReportsPage.class);
	mountPage("/useractivity", UserActivityPage.class);
	mountPage("/preferences", PreferencesPage.class);
	
	// On wicket session timeout, redirect to main page
	getApplicationSettings().setPageExpiredErrorPage(OverviewPage.class);
	getApplicationSettings().setAccessDeniedPage(OverviewPage.class);

	// Debugging
	debug = ServerConfigurationService.getBoolean("sitestats.debug", false);
	if(debug) {
		getDebugSettings().setComponentUseCheck(true);
		getDebugSettings().setAjaxDebugModeEnabled(true);
	    getDebugSettings().setLinePreciseReportingOnAddComponentEnabled(true);
	    getDebugSettings().setLinePreciseReportingOnNewComponentEnabled(true);
	    getDebugSettings().setOutputComponentPath(true);
	    getDebugSettings().setOutputMarkupContainerClassName(true);
		getDebugSettings().setDevelopmentUtilitiesEnabled(true);
	    getMarkupSettings().setStripWicketTags(false);
		getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_EXCEPTION_PAGE);
		// register standard debug contributors so that just setting the sitestats.debug property is enough to turn these on
		// otherwise, you have to turn wicket development mode on to get this populated due to the order methods are called
		DebugBar.registerContributor(VersionDebugContributor.DEBUG_BAR_CONTRIB, this);
		DebugBar.registerContributor(InspectorDebugPanel.DEBUG_BAR_CONTRIB, this);
		DebugBar.registerContributor(SessionSizeDebugPanel.DEBUG_BAR_CONTRIB, this);
		DebugBar.registerContributor(PageSizeDebugPanel.DEBUG_BAR_CONTRIB, this);
	}
	else
	{
		// Throw RuntimeDeceptions so they are caught by the Sakai ErrorReportHandler
		getRequestCycleListeners().add(new AbstractRequestCycleListener()
		{
			@Override
			public IRequestHandler onException(RequestCycle cycle, Exception ex)
			{
				if (ex instanceof RuntimeException)
				{
					throw (RuntimeException) ex;
				}
				return null;
			}
		});
	}

	// Encrypt URLs. This immediately sets up a session (note that things like CSS now becomes bound to the session)
	getSecuritySettings().setCryptFactory(new KeyInSessionSunJceCryptFactory()); // Different key per user
	final IRequestMapper cryptoMapper = new CryptoMapper(getRootRequestMapper(), this); 
	setRootRequestMapper(cryptoMapper);
}
 
Example #4
Source File: GradebookNgApplication.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
public void init() {
	super.init();

	// page mounting for bookmarkable URLs
	mountPage("/grades", GradebookPage.class);
	mountPage("/settings", SettingsPage.class);
	mountPage("/importexport", ImportExportPage.class);
	mountPage("/permissions", PermissionsPage.class);
	mountPage("/gradebook", StudentPage.class);
	mountPage("/accessdenied", AccessDeniedPage.class);
	mountPage("/error", ErrorPage.class);

	// remove the version number from the URL so that browser refreshes re-render the page
	getRequestCycleSettings().setRenderStrategy(RenderStrategy.ONE_PASS_RENDER);

	// Configure for Spring injection
	getComponentInstantiationListeners().add(new SpringComponentInjector(this));

	// Add ResourceLoader that integrates with Sakai's Resource Loader
	getResourceSettings().getStringResourceLoaders().add(0, new GradebookNgStringResourceLoader());

	// Don't throw an exception if we are missing a property, just fallback
	getResourceSettings().setThrowExceptionOnMissingResource(false);

	// Remove the wicket specific tags from the generated markup
	getMarkupSettings().setStripWicketTags(true);

	// Don't add any extra tags around a disabled link (default is <em></em>)
	getMarkupSettings().setDefaultBeforeDisabledLink(null);
	getMarkupSettings().setDefaultAfterDisabledLink(null);

	// On Wicket session timeout, redirect to main page
	// getApplicationSettings().setPageExpiredErrorPage(getHomePage());

	// Intercept any unexpected error stacktrace and take to our page
	getRequestCycleListeners().add(new AbstractRequestCycleListener() {
		@Override
		public IRequestHandler onException(final RequestCycle cycle, final Exception e) {
			return new RenderPageRequestHandler(new PageProvider(new ErrorPage(e)));
		}
	});

	// Disable Wicket's loading of jQuery - we load Sakai's preferred version in BasePage.java
	getJavaScriptLibrarySettings().setJQueryReference(new PackageResourceReference(GradebookNgApplication.class, "empty.js"));

	// cleanup the HTML
	getMarkupSettings().setStripWicketTags(true);
	getMarkupSettings().setStripComments(true);
	getMarkupSettings().setCompressWhitespace(true);
}
 
Example #5
Source File: SiteStatsApplication.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
protected void init() {
	super.init();

	// Configure general wicket application settings
	getComponentInstantiationListeners().add(new SpringComponentInjector(this));
	getResourceSettings().setThrowExceptionOnMissingResource(false);
	getMarkupSettings().setStripWicketTags(true);
	getResourceSettings().getStringResourceLoaders().add(new SiteStatsStringResourceLoader());
	getResourceSettings().getResourceFinders().add(new WebApplicationPath(getServletContext(), "html"));
	getResourceSettings().setResourceStreamLocator(new SiteStatsResourceStreamLocator());
	getDebugSettings().setAjaxDebugModeEnabled(debug);

	// configure bottom page script loading
	setHeaderResponseDecorator(new JavaScriptToBucketResponseDecorator("bottom-script-container"));

	// Mount pages
	mountPage("/home", OverviewPage.class);
	mountPage("/reports", ReportsPage.class);
	mountPage("/useractivity", UserActivityPage.class);
	mountPage("/preferences", PreferencesPage.class);
	
	// On wicket session timeout, redirect to main page
	getApplicationSettings().setPageExpiredErrorPage(OverviewPage.class);
	getApplicationSettings().setAccessDeniedPage(OverviewPage.class);

	// Debugging
	debug = ServerConfigurationService.getBoolean("sitestats.debug", false);
	if(debug) {
		getDebugSettings().setComponentUseCheck(true);
		getDebugSettings().setAjaxDebugModeEnabled(true);
	    getDebugSettings().setLinePreciseReportingOnAddComponentEnabled(true);
	    getDebugSettings().setLinePreciseReportingOnNewComponentEnabled(true);
	    getDebugSettings().setOutputComponentPath(true);
	    getDebugSettings().setOutputMarkupContainerClassName(true);
		getDebugSettings().setDevelopmentUtilitiesEnabled(true);
	    getMarkupSettings().setStripWicketTags(false);
		getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_EXCEPTION_PAGE);
		// register standard debug contributors so that just setting the sitestats.debug property is enough to turn these on
		// otherwise, you have to turn wicket development mode on to get this populated due to the order methods are called
		DebugBar.registerContributor(VersionDebugContributor.DEBUG_BAR_CONTRIB, this);
		DebugBar.registerContributor(InspectorDebugPanel.DEBUG_BAR_CONTRIB, this);
		DebugBar.registerContributor(SessionSizeDebugPanel.DEBUG_BAR_CONTRIB, this);
		DebugBar.registerContributor(PageSizeDebugPanel.DEBUG_BAR_CONTRIB, this);
	}
	else
	{
		// Throw RuntimeDeceptions so they are caught by the Sakai ErrorReportHandler
		getRequestCycleListeners().add(new AbstractRequestCycleListener()
		{
			@Override
			public IRequestHandler onException(RequestCycle cycle, Exception ex)
			{
				if (ex instanceof RuntimeException)
				{
					throw (RuntimeException) ex;
				}
				return null;
			}
		});
	}

	// Encrypt URLs. This immediately sets up a session (note that things like CSS now becomes bound to the session)
	getSecuritySettings().setCryptFactory(new KeyInSessionSunJceCryptFactory()); // Different key per user
	final IRequestMapper cryptoMapper = new CryptoMapper(getRootRequestMapper(), this); 
	setRootRequestMapper(cryptoMapper);
}
 
Example #6
Source File: GradebookNgApplication.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
public void init() {
	super.init();

	// page mounting for bookmarkable URLs
	mountPage("/grades", GradebookPage.class);
	mountPage("/settings", SettingsPage.class);
	mountPage("/importexport", ImportExportPage.class);
	mountPage("/permissions", PermissionsPage.class);
	mountPage("/gradebook", StudentPage.class);
	mountPage("/accessdenied", AccessDeniedPage.class);
	mountPage("/error", ErrorPage.class);

	// remove the version number from the URL so that browser refreshes re-render the page
	getRequestCycleSettings().setRenderStrategy(RenderStrategy.ONE_PASS_RENDER);

	// Configure for Spring injection
	getComponentInstantiationListeners().add(new SpringComponentInjector(this));

	// Add ResourceLoader that integrates with Sakai's Resource Loader
	getResourceSettings().getStringResourceLoaders().add(0, new GradebookNgStringResourceLoader());

	// Don't throw an exception if we are missing a property, just fallback
	getResourceSettings().setThrowExceptionOnMissingResource(false);

	// Remove the wicket specific tags from the generated markup
	getMarkupSettings().setStripWicketTags(true);

	// Don't add any extra tags around a disabled link (default is <em></em>)
	getMarkupSettings().setDefaultBeforeDisabledLink(null);
	getMarkupSettings().setDefaultAfterDisabledLink(null);

	// On Wicket session timeout, redirect to main page
	// getApplicationSettings().setPageExpiredErrorPage(getHomePage());

	// Intercept any unexpected error stacktrace and take to our page
	getRequestCycleListeners().add(new AbstractRequestCycleListener() {
		@Override
		public IRequestHandler onException(final RequestCycle cycle, final Exception e) {
			return new RenderPageRequestHandler(new PageProvider(new ErrorPage(e)));
		}
	});

	// Disable Wicket's loading of jQuery - we load Sakai's preferred version in BasePage.java
	getJavaScriptLibrarySettings().setJQueryReference(new PackageResourceReference(GradebookNgApplication.class, "empty.js"));

	// cleanup the HTML
	getMarkupSettings().setStripWicketTags(true);
	getMarkupSettings().setStripComments(true);
	getMarkupSettings().setCompressWhitespace(true);
}