You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Grigorov (Updated) (JIRA)" <ji...@apache.org> on 2012/04/03 15:04:25 UTC

[jira] [Updated] (WICKET-4350) Add more programmatic support for web app construction via servlet 3.0

     [ https://issues.apache.org/jira/browse/WICKET-4350?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Grigorov updated WICKET-4350:
------------------------------------

    Attachment: javax.servlet.ServletContainerInitializer
                Start.java
                Initializer.java

Here is a set of files which make it working in Jetty. Start.java is only needed for embedded Jetty.
The key is that DefaultServlet needs to be registered as well. Otherwise WicketFilter has nothing to filter and there is no one to serve static resources.
                
> Add more programmatic support for web app construction via servlet 3.0 
> -----------------------------------------------------------------------
>
>                 Key: WICKET-4350
>                 URL: https://issues.apache.org/jira/browse/WICKET-4350
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.5.4, 6.0.0-beta1
>            Reporter: Peter Ertl
>            Assignee: Peter Ertl
>            Priority: Minor
>             Fix For: 1.5.5, 6.0.0-beta1
>
>         Attachments: Initializer.java, Start.java, javax.servlet.ServletContainerInitializer
>
>
> Since servlet 3.0 web applications can be set up completely in code.
> To support this kind of setup wicket should
> - support the manual assignment of an web application instance to WicketFilter
> - support setting the runtime configuration type in WebApplication programmtically through a setter instead of reading web.xml
> sample code for demonstrating the use case:
> public class AppContextListener implements ServletContextListener
> {
> 	private GuiceContext guiceContext;
> 	@Override
> 	public void contextInitialized(ServletContextEvent sce)
> 	{
> 		// create configuration
> 		final AppConfig configuration = new WebAppConfig();
> 		// setup guice
> 		guiceContext = new GuiceContext(configuration);
> 		// create injector
> 		final Injector injector = guiceContext.createInjector();
> 		// create wicket application
> 		WebApplication application = injector.getInstance(WebApplication.class);
> 		application.setConfigurationType(RuntimeConfigurationType.DEVELOPMENT);
> 		// create wicket filter
> 		WicketFilter filter = new WicketFilter(application);
> 		filter.setFilterPath("");
>     // dynamically add wicket filter
> 		final FilterRegistration.Dynamic wicket = sce.getServletContext().addFilter("wicket", filter);
> 		// add filter mapping for path '/'
> 		wicket.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
> 	}
> 	
>   // ...
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira