01: /*
02: * Copyright 2002-2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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:
17: package info.jtrac.wicket;
18:
19: import info.jtrac.Jtrac;
20: import info.jtrac.domain.ItemSearch;
21: import info.jtrac.domain.Space;
22: import info.jtrac.domain.User;
23: import org.apache.wicket.markup.html.WebPage;
24: import org.apache.wicket.markup.html.basic.Label;
25: import org.slf4j.Logger;
26: import org.slf4j.LoggerFactory;
27:
28: /**
29: * base class for all wicket pages, this provides
30: * a way to access the spring managed service layer
31: * also takes care of the standard template for all
32: * pages which is using wicket markup inheritance
33: */
34: public abstract class BasePage extends WebPage {
35:
36: protected static final Logger logger = LoggerFactory
37: .getLogger(BasePage.class);
38:
39: protected Jtrac getJtrac() {
40: return ComponentUtils.getJtrac(this );
41: }
42:
43: protected User getPrincipal() {
44: return ComponentUtils.getPrincipal(this );
45: }
46:
47: protected void setCurrentSpace(Space space) {
48: ComponentUtils.setCurrentSpace(this , space);
49: }
50:
51: protected Space getCurrentSpace() {
52: return ComponentUtils.getCurrentSpace(this );
53: }
54:
55: protected void setCurrentItemSearch(ItemSearch itemSearch) {
56: ComponentUtils.setCurrentItemSearch(this , itemSearch);
57: }
58:
59: protected ItemSearch getCurrentItemSearch() {
60: return ComponentUtils.getCurrentItemSearch(this );
61: }
62:
63: protected String localize(String key) {
64: return ComponentUtils.localize(this , key);
65: }
66:
67: protected String localize(String key, Object... params) {
68: return ComponentUtils.localize(this , key, params);
69: }
70:
71: protected void refreshPrincipal(User user) {
72: ComponentUtils.refreshPrincipal(this , user);
73: }
74:
75: protected void refreshPrincipal() {
76: ComponentUtils.refreshPrincipal(this );
77: }
78:
79: public BasePage() {
80: add(new HeaderPanel().setRenderBodyOnly(true));
81: String jtracVersion = ComponentUtils.getJtrac(this )
82: .getReleaseVersion();
83: add(new Label("version", jtracVersion));
84: }
85:
86: }
|