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.markup.html.resources;
18:
19: import java.util.Locale;
20:
21: import org.apache.wicket.Resource;
22: import org.apache.wicket.ResourceReference;
23: import org.apache.wicket.markup.html.JavascriptPackageResource;
24: import org.apache.wicket.markup.html.PackageResource;
25:
26: /**
27: * Static resource reference for javacript resources. The resources are filtered
28: * (stripped comments and whitespace) and gzipped.
29: *
30: * @author Matej Knopp
31: */
32: public class JavascriptResourceReference extends ResourceReference {
33: private static final long serialVersionUID = 1L;
34:
35: /**
36: * Creates a new javascript resource reference.
37: * @param scope
38: * @param name
39: * @param locale
40: * @param style
41: */
42: public JavascriptResourceReference(Class scope, String name,
43: Locale locale, String style) {
44: super (scope, name, locale, style);
45: }
46:
47: /**
48: * Creates a new javascript resource reference.
49: * @param scope
50: * @param name
51: */
52: public JavascriptResourceReference(Class scope, String name) {
53: super (scope, name);
54: }
55:
56: /**
57: * Creates a new javascript resource reference.
58: * @param name
59: */
60: public JavascriptResourceReference(String name) {
61: super (name);
62: }
63:
64: protected Resource newResource() {
65: PackageResource packageResource = JavascriptPackageResource
66: .get(getScope(), getName(), getLocale(), getStyle());
67: if (packageResource != null) {
68: locale = packageResource.getLocale();
69: } else {
70: throw new IllegalArgumentException(
71: "package resource [scope=" + getScope() + ",name="
72: + getName() + ",locale=" + getLocale()
73: + "style=" + getStyle() + "] not found");
74: }
75: return packageResource;
76: }
77: }
|