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

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

Fixed images resources: moved them into src/main/resources - which is now also picked up by maven, and use package resource mechanism of wicket to refer to them (shortcut via Image constructor)

File size: 1.7 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;
8
9/**
10 * Panel showing a landing page link.
11 *
12 * In the extension of the link panel class, this class adds a label text and
13 * an icon that is specific for search page links
14 *
15 * @author keeloo
16 */
17public class LandingPageLinkPanel extends LinkPanel {
18
19    private final static ImageResource LANDINGPAGE_ICON =
20            new ImageResource(
21            "Crystal_Clear_mimetype_readme.png",
22            "Landing page");
23
24    /**
25     * Panel constructor.
26     *
27     * @param id Wicket mark up identifier
28     * @param resourceLink URL to pointing to the resource.
29     */
30    public LandingPageLinkPanel(String id, String resourceLink) {
31        // ...
32        super(id);
33       
34        // add the icon image
35        ImageResource imageResource = LANDINGPAGE_ICON;
36        Image resourceImg = new Image("landingPageImage", imageResource.getResource());
37       
38        // add the image's title
39        String title;
40        title = imageResource.getTitle();
41        resourceImg.add(new AttributeModifier("title", title));
42        resourceImg.add(new AttributeModifier("alt", title));
43       
44        // ...
45        String href = getHref(resourceLink);
46       
47        // get the name associated with the link
48        String name = getNameFromLink(resourceLink);
49
50        // ... and add the link itself
51        ExternalLink link = new ExternalLink("landingPageLink", href);
52        link.add(resourceImg);
53        link.add(new Label("landingPageLabel", name));
54        add(link);
55    }
56}
Note: See TracBrowser for help on using the repository browser.