8339000e32d07158e1dd8e72ac180a485e90c7a7
[photos] / src / main / java / org / wamblee / photos / wicket / WicketApplication.java
1 /*
2  * Copyright 2005-2010 the original author or authors.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.wamblee.photos.wicket;
17
18 import javax.servlet.http.HttpServletRequest;
19
20 import org.apache.wicket.Request;
21 import org.apache.wicket.RequestCycle;
22 import org.apache.wicket.Response;
23 import org.apache.wicket.protocol.http.WebApplication;
24 import org.apache.wicket.protocol.http.WebRequest;
25 import org.apache.wicket.request.target.basic.RedirectRequestTarget;
26 import org.apache.wicket.settings.IApplicationSettings;
27 import org.wamblee.wicket.inject.ComponentInstantiationInjector;
28 import org.wamblee.wicket.transactions.OpenTransactionInViewRequestCycle;
29
30 /**
31  * Application object for your web application. If you want to run this
32  * application without deploying, run the Start class.
33  * 
34  * @see org.wamblee.Start#main(String[])
35  */
36 public class WicketApplication extends WebApplication {
37
38     /**
39      * Constructor
40      */
41     public WicketApplication() {
42         // Empty.
43     }
44
45     @Override
46     public RequestCycle newRequestCycle(Request aRequest, Response aResponse) {
47         return new OpenTransactionInViewRequestCycle(this,
48             (WebRequest) aRequest, aResponse);
49     }
50
51     @Override
52     protected void init() {
53         super.init();
54         addComponentInstantiationListener(new ComponentInstantiationInjector());
55
56         IApplicationSettings settings = getApplicationSettings();
57         settings.setInternalErrorPage(ErrorPage.class);
58
59         // Use the lines below to get the internal error page also when in
60         // development mode.
61         // IExceptionSettings exs = getExceptionSettings();
62         // exs.setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
63     }
64
65     /**
66      * @see org.apache.wicket.Application#getHomePage()
67      */
68     public Class<HomePage> getHomePage() {
69         return HomePage.class;
70     }
71
72 }