source: vlo/branches/to-wicket-1.6/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/pages/SearchPageLinkPanel.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.behavior.SimpleAttributeModifier;
6import org.apache.wicket.markup.html.basic.Label;
7import org.apache.wicket.markup.html.image.Image;
8import org.apache.wicket.markup.html.link.ExternalLink;
9import org.apache.wicket.resource.ContextRelativeResource;
10
11/**
12 * Panel showing a search 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 SearchPageLinkPanel extends LinkPanel {
20
21    private final static ImageResource SEARCHPAGE_ICON =
22            new ImageResource("Images/Crystal_Clear_action_filefind.png",
23            "Search page");
24
25    /**
26     * Panel constructor.
27     *
28     * @param id Wicket mark up identifier
29     * @param resourceLink URL to pointing to the resource
30     */
31    public SearchPageLinkPanel(String id, String resourceLink) {
32        // ...
33        super(id);
34       
35        // add the icon image
36        ImageResource imageResource = SEARCHPAGE_ICON;
37        Image resourceImg = new Image("searchPageImage", imageResource.getResource());
38       
39        // add the image's title
40        String title;
41        title = imageResource.getTitle();
42        resourceImg.add(new AttributeModifier("title", title));
43        resourceImg.add(new AttributeModifier("alt", title));
44
45        // ...
46        String href = getHref(resourceLink);
47
48        // get the name associated with the link
49        String name = getNameFromLink(resourceLink);
50       
51        // ... and add the link itself
52        ExternalLink link = new ExternalLink("searchPageLink", href);
53        link.add(resourceImg);
54        link.add(new Label("searchPageLabel", name));
55        add(link);
56    }
57}
Note: See TracBrowser for help on using the repository browser.