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

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

Introduction

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

Prototype

public ExternalLink setContextRelative(final boolean contextRelative) 

Source Link

Document

Set to true if this link should be automatically prepended with ../ to make it relative to the context root.

Usage

From source file:com.cubeia.games.poker.admin.wicket.pages.tournaments.payouts.CreateOrEditPayoutStructure.java

License:Open Source License

public CreateOrEditPayoutStructure(PageParameters p) {
    super(p);//  w w w  .java 2s.  c  o m
    add(new FileUploadForm("upload"));

    ExternalLink csvLink = new ExternalLink("csvLink", "/payouts/default_payouts.csv");
    csvLink.setContextRelative(true);
    add(csvLink);
}

From source file:gr.abiss.calipso.wicket.HeaderPanel.java

License:Open Source License

public HeaderPanel() {
    super("header");

    final User user = getPrincipal();
    final List<Space> spaces = user != null ? new ArrayList<Space>(user.getSpaces()) : new ArrayList<Space>();

    boolean hideLogin = BooleanUtils.toBoolean(getCalipso().loadConfig("calipso.hideLoginLink"));
    boolean hideRegister = BooleanUtils.toBoolean(getCalipso().loadConfig("calipso.hideRegisterLink"));
    // manage single space
    if (spaces.size() == 1) {
        setCurrentSpace(spaces.get(0));/*from   w w  w. ja  v a2 s .  c  om*/
    }
    final Space space = getCurrentSpace();
    Component link = null;
    if (getPrincipal().isAnonymous()) {
        ExternalLink externalLink = new ExternalLink("dashboard", "/");
        externalLink.setContextRelative(true);
        link = externalLink;
    } else {
        link = new Link("dashboard") {
            public void onClick() {
                setCurrentSpace(null);
                setResponsePage(DashboardPage.class);
            }
        };
    }
    add(link);

    if (space == null) {

        // add(new Label("space", "").setVisible(false));// 1
        // add(new Label("new", "").setVisible(false));// 2
        add(new Link("search") {// 3
            public void onClick() {
                setResponsePage(ItemSearchFormPage.class);
            }
        }.setVisible(user != null && user.getSpaceCount() > 0 && !user.isAnonymous()));
    } else {
        /*
         * add(new Link("space") {
         * 
         * @Override public void onClick() {
         * setResponsePage(SpacePage.class); } }.add(new Label("space",
         * space.getName())));
         */
        // add(new WebMarkupContainer("space").add(new Label("space",
        // space.getName())));

        // In case that User opens an Item direct from e-mail notification
        // link
        // and has no access to this Item
        /*
         * try { if (user.getPermittedTransitions(space, State.NEW).size() >
         * 0) { add(new Link("new") { public void onClick() {
         * setResponsePage(ItemFormPage.class); } }); } else { add(new
         * WebMarkupContainer("new").setVisible(false)); } } catch
         * (Exception e) { logger.error("user.getPermittedTransitions :: " +
         * e.getMessage()); add(new
         * WebMarkupContainer("new").setVisible(false)); }
         */
        add(new Link("search") {
            public void onClick() {
                // if search then we user global search
                setCurrentSpace(null);
                setResponsePage(ItemSearchFormPage.class);
            }
        }.setVisible(user.getSpaceCount() > 0 && !user.isAnonymous()));
    }

    if (user == null || user.getId() == 0) {
        add(new WebMarkupContainer("options").setVisible(false));
        add(new WebMarkupContainer("logout").setVisible(false));
        add(new Link("login") {
            public void onClick() {
                setResponsePage(LoginPage.class);
            }
        }.setVisible(!hideLogin));
        add(new Link("register") {
            public void onClick() {
                setResponsePage(RegisterAnonymousUserFormPage.class);
            }
        }.setVisible(!hideRegister));
        add(new WebMarkupContainer("user").setVisible(false));
    } else {
        add(new Link("options") {
            public void onClick() {
                // when options clicked then we go to menu that space
                // doesn't have meaning
                setCurrentSpace(null);
                setResponsePage(OptionsPage.class);
            }
        });
        add(new Link("logout") {
            public void onClick() {
                Cookie cookie = new Cookie("calipsoService", "");
                String path = ((WebRequest) getRequest()).getContextPath();
                cookie.setPath(path);
                ((WebResponse) getResponse()).clearCookie(cookie);
                getSession().invalidate();
                logger.debug("invalidated session and cleared cookie");
                // is acegi - cas being used ?
                String logoutUrl = ((CalipsoApplication) getApplication()).getCasLogoutUrl();
                if (logoutUrl != null) {
                    logger.debug(
                            "cas authentication being used, clearing security context and redirecting to cas logout page");
                    SecurityContextHolder.clearContext();
                    // have to use stateless page reference because session
                    // is killed
                    setResponsePage(CasLogoutPage.class);
                } else {
                    setResponsePage(LogoutPage.class, new PageParameters("locale=" + user.getLocale()));
                }
            }
        });
        add(new WebMarkupContainer("login").setVisible(false));
        // issue
        add(new WebMarkupContainer("register").setVisible(false));

        add(new Link("user") {
            public void onClick() {
                setResponsePage(new UserViewPage(user));
            }
        }.add(new Label("user", user.getDisplayValue()).setRenderBodyOnly(true)));
    }
}