1 | package eu.clarin.cmdi.vlo.pages; |
---|
2 | |
---|
3 | import eu.clarin.cmdi.vlo.VloWebApplication; |
---|
4 | import eu.clarin.cmdi.vlo.VloSession; |
---|
5 | import org.apache.wicket.markup.head.CssHeaderItem; |
---|
6 | import org.apache.wicket.markup.head.IHeaderResponse; |
---|
7 | import org.apache.wicket.request.mapper.parameter.PageParameters; |
---|
8 | import org.apache.wicket.markup.html.IHeaderContributor; |
---|
9 | import org.apache.wicket.markup.html.WebPage; |
---|
10 | import org.apache.wicket.markup.html.basic.Label; |
---|
11 | import org.apache.wicket.markup.html.image.Image; |
---|
12 | import org.apache.wicket.markup.html.link.BookmarkablePageLink; |
---|
13 | import org.apache.wicket.request.resource.ContextRelativeResource; |
---|
14 | |
---|
15 | /** |
---|
16 | * Properties common to all VLO web application's page objects |
---|
17 | * |
---|
18 | * @author keeloo |
---|
19 | */ |
---|
20 | public class BasePage extends WebPage implements IHeaderContributor{ |
---|
21 | |
---|
22 | // reference to the web application object |
---|
23 | static VloWebApplication webApp; |
---|
24 | |
---|
25 | /** |
---|
26 | * Make sure every web application object sends this message |
---|
27 | * |
---|
28 | * @param vloWebApplication reference to the web application object |
---|
29 | */ |
---|
30 | public static void setWebApp(VloWebApplication vloWebApplication) { |
---|
31 | webApp = vloWebApplication; |
---|
32 | } |
---|
33 | |
---|
34 | /** |
---|
35 | * Install a VLO theme<br><br> |
---|
36 | * |
---|
37 | * A VLO theme is determined by a page title, a CSS file, and a banner split |
---|
38 | * in a left and right image. |
---|
39 | * |
---|
40 | * The left part of the banner serves as a link to the faceted search page, |
---|
41 | * the application's start page. In the field below banner there is a link |
---|
42 | * to the page the web application is launched from; the applications home |
---|
43 | * page. This link page is defined in the VloConfig file. |
---|
44 | * |
---|
45 | * @param parameters |
---|
46 | */ |
---|
47 | public BasePage(PageParameters parameters) { |
---|
48 | |
---|
49 | super(parameters); |
---|
50 | |
---|
51 | // set the page title |
---|
52 | |
---|
53 | Label pageTitle; |
---|
54 | pageTitle = new Label ("pagetitle", VloSession.get().getCurrentTheme().pageTitle); |
---|
55 | add (pageTitle); |
---|
56 | |
---|
57 | // set the applications start page link to the faceted search page |
---|
58 | PageParameters startPageParameters = new PageParameters (); |
---|
59 | // add the session persistent parameters |
---|
60 | startPageParameters.mergeWith(VloSession.get().getVloSessionPageParameters()); |
---|
61 | |
---|
62 | BookmarkablePageLink link = new BookmarkablePageLink("startpage", |
---|
63 | FacetedSearchPage.class, startPageParameters); |
---|
64 | add(link); |
---|
65 | |
---|
66 | // refer to the the left part of the vlo banner as a resource |
---|
67 | ContextRelativeResource leftImageRes; |
---|
68 | leftImageRes = new ContextRelativeResource(VloSession.get().getCurrentTheme().topLeftImage); |
---|
69 | |
---|
70 | // create the image |
---|
71 | Image leftImage; |
---|
72 | leftImage = new Image("leftimage", leftImageRes); |
---|
73 | |
---|
74 | // add the image to the page |
---|
75 | link.add(leftImage); |
---|
76 | |
---|
77 | // refer to the right part of the vlo banner as a resource |
---|
78 | ContextRelativeResource rightImageRes; |
---|
79 | rightImageRes = new ContextRelativeResource(VloSession.get().getCurrentTheme().topRightImage); |
---|
80 | |
---|
81 | // create the image |
---|
82 | Image rightImage; |
---|
83 | rightImage = new Image("rightimage", rightImageRes); |
---|
84 | |
---|
85 | // add it to the page |
---|
86 | add (rightImage); |
---|
87 | |
---|
88 | // set the partnerlinks |
---|
89 | |
---|
90 | Label partnerLinkMap; |
---|
91 | partnerLinkMap = new Label ("partnerlinkmap", VloSession.get().getCurrentTheme().partnerLinkMap); |
---|
92 | partnerLinkMap.setEscapeModelStrings(false); |
---|
93 | add (partnerLinkMap); |
---|
94 | } |
---|
95 | |
---|
96 | /** |
---|
97 | * Include the theme's CSS file in the HTML page<br><br> |
---|
98 | * |
---|
99 | * This method is invoked when Wicket renders a VLO page. |
---|
100 | * |
---|
101 | * @param response |
---|
102 | */ |
---|
103 | public void renderHead(IHeaderResponse response) { |
---|
104 | response.render(CssHeaderItem.forUrl(VloSession.get().getCurrentTheme().cssFile)); |
---|
105 | } |
---|
106 | } |
---|