Example usage for org.apache.wicket.markup.html.link ExternalLink getMarkupId

List of usage examples for org.apache.wicket.markup.html.link ExternalLink getMarkupId

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.link ExternalLink getMarkupId.

Prototype

public String getMarkupId() 

Source Link

Document

Retrieves id by which this component is represented within the markup.

Usage

From source file:org.sakaiproject.sitestats.tool.wicket.widget.Widget.java

License:Educational Community License

private void renderWidget() {
    setRenderBodyOnly(true);//w w w.  java2s. com
    removeAll();

    // Icon
    add(new ExternalImage("icon", iconUrl));

    // Title
    add(new Label("title", title));

    // Show more/less links
    ExternalLink showMore = new ExternalLink("showMore", "#");
    showMore.setOutputMarkupId(true);
    add(showMore);
    ExternalLink showLess = new ExternalLink("showLess", "#");
    showLess.setOutputMarkupId(true);
    add(showLess);

    // Content details (middle)
    WebMarkupContainer middle = new WebMarkupContainer("middle");
    middle.setOutputMarkupId(true);
    add(middle);

    // MiniStats ajax load behavior
    AjaxLazyLoadFragment ministatContainer = new AjaxLazyLoadFragment("ministatContainer") {
        private static final long serialVersionUID = 12L;

        @Override
        public Fragment getLazyLoadFragment(String markupId) {
            return Widget.this.getLazyLoadedMiniStats(markupId);
        }

        @Override
        public Component getLoadingComponent(String markupId) {
            StringBuilder loadingComp = new StringBuilder();
            loadingComp.append("<div class=\"ministat load\">");
            loadingComp.append("  <img src=\"");
            loadingComp.append(RequestCycle.get().urlFor(AbstractDefaultAjaxBehavior.INDICATOR, null));
            loadingComp.append("\"/>");
            loadingComp.append("</div>");
            return new Label(markupId, loadingComp.toString()).setEscapeModelStrings(false);
        }
    };
    add(ministatContainer);

    // Tabs
    WidgetTabs widgetTabs = new WidgetTabs("widgetTabs", tabs, 0);
    middle.add(widgetTabs);

    // Links behaviors
    String showMoreOnclick = "showMoreLess('#" + middle.getMarkupId() + "', '#" + showMore.getMarkupId()
            + "','#" + showLess.getMarkupId() + "');return false;";
    showMore.add(AttributeModifier.replace("onclick", showMoreOnclick));
    String showLessOnclick = "showMoreLess('#" + middle.getMarkupId() + "', '#" + showMore.getMarkupId()
            + "','#" + showLess.getMarkupId() + "');return false;";
    showLess.add(AttributeModifier.replace("onclick", showLessOnclick));
}