source: vlo/branches/to-wicket-1.6/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/pages/BasePage.java @ 4220

Last change on this file since 4220 was 4220, checked in by twagoo, 10 years ago

Merged twagoo branch of to-wicket-1.6 back to original, removed this branch

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