01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.wicket.examples.upload;
18:
19: import javax.servlet.http.HttpServletRequest;
20:
21: import org.apache.wicket.examples.WicketExampleApplication;
22: import org.apache.wicket.extensions.ajax.markup.html.form.upload.UploadWebRequest;
23: import org.apache.wicket.protocol.http.WebRequest;
24: import org.apache.wicket.util.file.Folder;
25:
26: /**
27: * Application class for org.apache.wicket.examples.upload example.
28: *
29: * @author Eelco Hillenius
30: */
31: public class UploadApplication extends WicketExampleApplication {
32: private Folder uploadFolder = null;
33:
34: /**
35: * Constructor.
36: */
37: public UploadApplication() {
38: }
39:
40: /**
41: * @see org.apache.wicket.Application#getHomePage()
42: */
43: public Class getHomePage() {
44: return UploadPage.class;
45: }
46:
47: /**
48: * @return the folder for uploads
49: */
50: public Folder getUploadFolder() {
51: return uploadFolder;
52: }
53:
54: /**
55: * @see org.apache.wicket.examples.WicketExampleApplication#init()
56: */
57: protected void init() {
58: getResourceSettings().setThrowExceptionOnMissingResource(false);
59:
60: uploadFolder = new Folder(System.getProperty("java.io.tmpdir"),
61: "wicket-uploads");
62: // Ensure folder exists
63: uploadFolder.mkdirs();
64:
65: mountBookmarkablePage("/multi", MultiUploadPage.class);
66: mountBookmarkablePage("/single", UploadPage.class);
67:
68: }
69:
70: /**
71: * @see org.apache.wicket.protocol.http.WebApplication#newWebRequest(javax.servlet.http.HttpServletRequest)
72: */
73: protected WebRequest newWebRequest(HttpServletRequest servletRequest) {
74: return new UploadWebRequest(servletRequest);
75: }
76: }
|