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

Last change on this file since 4199 was 4199, checked in by keeloo, 10 years ago
File size: 1.8 KB
Line 
1
2package eu.clarin.cmdi.vlo.pages;
3
4import org.apache.wicket.AttributeModifier;
5import org.apache.wicket.markup.html.basic.Label;
6import org.apache.wicket.markup.html.image.Image;
7import org.apache.wicket.markup.html.link.ExternalLink;
8import org.apache.wicket.request.resource.ResourceReference;
9import org.apache.wicket.resource.ContextRelativeResource;
10
11/**
12 * Panel showing a landing page link.
13 *
14 * In the extension of the link panel class, this class adds a label text and
15 * an icon that is specific for search page links
16 *
17 * @author keeloo
18 */
19public class LandingPageLinkPanel extends LinkPanel {
20
21    private final static ImageResource LANDINGPAGE_ICON =
22            new ImageResource(
23            "Images/Crystal_Clear_mimetype_readme.png",
24            "Landing page");
25
26    /**
27     * Panel constructor.
28     *
29     * @param id Wicket mark up identifier
30     * @param resourceLink URL to pointing to the resource.
31     */
32    public LandingPageLinkPanel(String id, String resourceLink) {
33        // ...
34        super(id);
35       
36        // add the icon image
37        ImageResource imageResource = LANDINGPAGE_ICON;
38        Image resourceImg = new Image("landingPageImage", imageResource.getResource());
39       
40        // add the image's title
41        String title;
42        title = imageResource.getTitle();
43        resourceImg.add(new AttributeModifier("title", title));
44        resourceImg.add(new AttributeModifier("alt", title));
45       
46        // ...
47        String href = getHref(resourceLink);
48       
49        // get the name associated with the link
50        String name = getNameFromLink(resourceLink);
51
52        // ... and add the link itself
53        ExternalLink link = new ExternalLink("landingPageLink", href);
54        link.add(resourceImg);
55        link.add(new Label("landingPageLabel", name));
56        add(link);
57    }
58}
Note: See TracBrowser for help on using the repository browser.