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

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

Introduction

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

Prototype

public ExternalLink(final String id, final IModel<String> href) 

Source Link

Document

Constructor.

Usage

From source file:at.molindo.esi4j.example.web.HomePage.java

License:Apache License

public HomePage() {
    add(new UrlSubmissionForm("urlForm"));

    _searchModel = new AbstractReadOnlyModel<Search>() {
        private final Search _search = new Search();

        @Override//from   w ww  .  j  ava  2 s  . c om
        public Search getObject() {
            return _search;
        }
    };

    _searchResponseModel = new LoadableDetachableModel<ListenableActionFuture<SearchResponseWrapper>>() {

        @Override
        protected ListenableActionFuture<SearchResponseWrapper> load() {
            Search search = _searchModel.getObject();
            return _searchService.search(search.getQuery(), search.getCategories());
        }

    };

    IModel<List<SearchHitWrapper>> articlesModel = new AbstractReadOnlyModel<List<SearchHitWrapper>>() {

        @Override
        public List<SearchHitWrapper> getObject() {
            return _searchResponseModel.getObject().actionGet().getSearchHits();
        }

    };

    IModel<List<? extends TermsFacet.Entry>> facetsModel = new AbstractReadOnlyModel<List<? extends TermsFacet.Entry>>() {

        @Override
        public List<? extends TermsFacet.Entry> getObject() {
            Facets facets = _searchResponseModel.getObject().actionGet().getSearchResponse().getFacets();
            if (facets == null) {
                return Collections.emptyList();
            }

            TermsFacet facet = (TermsFacet) facets.facet("categories");
            if (facet == null) {
                return Collections.emptyList();
            }

            return facet.getEntries();
        }

    };

    add(new TextField<String>("search", new PropertyModel<String>(_searchModel, "query"))
            .add(new OnChangeUpdateSearchBehavior()));

    // category select
    add(_facetsContainer = new CheckGroup<String>("facetsContainer"));
    _facetsContainer.setOutputMarkupId(true).setRenderBodyOnly(false);
    _facetsContainer.add(new ListView<TermsFacet.Entry>("categoryFacets", facetsModel) {

        @Override
        protected IModel<TermsFacet.Entry> getListItemModel(
                IModel<? extends List<TermsFacet.Entry>> listViewModel, int index) {
            return new CompoundPropertyModel<TermsFacet.Entry>(super.getListItemModel(listViewModel, index));
        }

        @Override
        protected void populateItem(final ListItem<Entry> item) {
            CheckBox box;
            item.add(box = new CheckBox("check", new IModel<Boolean>() {

                @Override
                public Boolean getObject() {
                    return _searchModel.getObject().getCategories().contains(item.getModelObject().getTerm());
                }

                @Override
                public void setObject(Boolean checked) {
                    List<String> categories = _searchModel.getObject().getCategories();
                    String category = item.getModelObject().getTerm().string();
                    if (Boolean.TRUE.equals(checked)) {
                        categories.add(category);
                    } else {
                        categories.remove(category);
                    }
                }

                @Override
                public void detach() {
                }

            }));
            box.add(new OnChangeUpdateSearchBehavior());

            item.add(new SimpleFormComponentLabel("term",
                    box.setLabel(new PropertyModel<String>(item.getModel(), "term"))));
            item.add(new Label("count"));
        }

    });

    // search results
    add(_container = new WebMarkupContainer("container"));
    _container.setOutputMarkupId(true);
    _container.add(new Label("query", _searchModel.getObject().getQuery()));
    _container.add(new ListView<SearchHitWrapper>("result", articlesModel) {

        @Override
        protected IModel<SearchHitWrapper> getListItemModel(
                IModel<? extends List<SearchHitWrapper>> listViewModel, int index) {
            return new CompoundPropertyModel<SearchHitWrapper>(super.getListItemModel(listViewModel, index));
        }

        @Override
        protected void populateItem(final ListItem<SearchHitWrapper> item) {
            item.add(new Label("object.subject"));
            item.add(new Label("object.date"));
            item.add(new Label("object.body", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    SearchHitWrapper wrapper = item.getModelObject();

                    HighlightField field = wrapper.getSearchHit().getHighlightFields().get("body");
                    if (field == null) {
                        return wrapper.getObject(Article.class).getBody();
                    }

                    Object[] fragments = field.getFragments();
                    if (fragments == null) {
                        return wrapper.getObject(Article.class).getBody();
                    }

                    return StringUtils.join(" ... ", fragments);
                }
            }));
            item.add(new ExternalLink("link", new PropertyModel<String>(item.getModel(), "object.url")));
            item.add(new ListView<String>("categories",
                    new PropertyModel<List<String>>(item.getModel(), "object.categories")) {

                @Override
                protected void populateItem(ListItem<String> item) {
                    item.add(new Label("name", item.getModel()));
                }
            });
        }

    });

    add(new IndicatingAjaxLink<Void>("rebuild") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            _searchService.rebuild();
            updateSearch(target);
        }

    });

    add(new IndicatingAjaxLink<Void>("delete") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            _articleService.deleteArticles();
            _searchService.refresh();
            updateSearch(target);
        }

    });
}

From source file:biz.turnonline.ecosystem.origin.frontend.page.Home.java

License:Apache License

public Home() {
    add(new ExternalLink("link-gcloud", "") {
        @Override/* w w  w. j a  va  2s . co  m*/
        protected void onInitialize() {
            super.onInitialize();

            String gcloudUrl = "https://console.cloud.google.com/home/dashboard?project=" + projectId;
            setDefaultModelObject(gcloudUrl);
            setBody(Model.of(gcloudUrl));
        }
    });

    add(new ExternalLink("link-firebase", "") {
        @Override
        protected void onInitialize() {
            super.onInitialize();

            String gcloudUrl = "https://console.firebase.google.com/u/0/project/" + projectId
                    + "/authentication/users";
            setDefaultModelObject(gcloudUrl);
            setBody(Model.of(gcloudUrl));
        }
    });

    InputStream identityPropertiesContentStream = Home.class
            .getResourceAsStream(API_CREDENTIAL_LOADER.getConfigurationFilePath());
    String identityPropertiesContent;
    try {
        identityPropertiesContent = CharStreams
                .toString(new InputStreamReader(identityPropertiesContentStream, Charsets.UTF_8));
    } catch (IOException e) {
        e.printStackTrace();
        identityPropertiesContent = "Error unable to load /api.properties";
    }
    add(new Label("identity-properties", identityPropertiesContent));
}

From source file:br.eti.ranieri.opcoesweb.page.PaginaBase.java

License:Apache License

public PaginaBase() {
    add(new BookmarkablePageLink("configurar", ConfigurarOnlinePage.class));
    add(new BookmarkablePageLink("exibirOnline", ExibirOnlinePage.class));
    add(new BookmarkablePageLink("importadorSerieHistorica", ImportarSerieHistoricaPage.class));
    add(new BookmarkablePageLink("exibirOffline", ExibirOfflinePage.class));
    add(new BookmarkablePageLink("calcularBlackScholesAdhoc", CalcularBlackScholesAdhocPage.class));
    add(new BookmarkablePageLink("wizardSimulacao", Wizard1SimulacaoPage.class));
    add(new ExternalLink("logoutLink", "/j_spring_security_logout").setContextRelative(true));
}

From source file:com.apachecon.memories.ScrapbookPage.java

License:Apache License

@SuppressWarnings({ "rawtypes", "unchecked" })
public ScrapbookPage() {
    add(new ExternalLink("apacheCon", "http://na11.apachecon.com/"));

    add(new BookmarkablePageLink("logo", Index.class));

    List<Class<? extends Page>> links = new ArrayList<Class<? extends Page>>();
    links.add(Index.class);
    links.add(Upload.class);
    Roles roles = AuthenticatedWebSession.get().getRoles();
    if (roles != null && roles.hasRole("admin")) {
        links.add(Browse.class);
        links.add(Approve.class);
        links.add(Logout.class);
    } else {/*from w w  w. jav a  2s.c om*/
        links.add(Browse.class);
        links.add(SignIn.class);
    }

    add(new ListView<Class>("menu", links) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<Class> item) {
            BookmarkablePageLink link = new BookmarkablePageLink("link", item.getModelObject());

            String simpleName = item.getModelObject().getSimpleName();

            if (getPage().getClass().equals(item.getModelObject())) {
                item.add(AttributeModifier.append("class", "active"));
            }

            link.add(new Label("label", simpleName));
            item.add(link);
        }
    });
}

From source file:com.axway.ats.testexplorer.pages.BasePage.java

License:Apache License

/**
 *
 * @return Testcase navigation buttons component
 *//*from  w  w  w  .  j  a  v  a 2  s .  c om*/
protected Component getTestcaseNavigationButtons() {

    WebMarkupContainer testcaseNavigationButtons = new WebMarkupContainer("testcaseNavigationButtons");
    testcaseNavigationButtons.setVisible(false);

    testcaseNavigationButtons.add(new ExternalLink("goToPrevTestcase", "#"));
    testcaseNavigationButtons.add(new ExternalLink("goToNextTestcase", "#"));
    testcaseNavigationButtons.add(new ExternalLink("goToLastTestcase", "#"));

    return testcaseNavigationButtons;
}

From source file:com.cubeia.backoffice.web.util.ExternalLinkPanel.java

License:Open Source License

public ExternalLinkPanel(String id, String text, String toolTip, String url) {
    super(id);//w w w . j a  va  2  s  .  co  m

    ExternalLink link = new ExternalLink("link", url);
    link.add(new Label("label", text));

    if (toolTip != null) {
        link.add(new AttributeModifier("title", Model.of(toolTip)));
    }

    add(link);
}

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 .ja v  a  2  s. co  m
    add(new FileUploadForm("upload"));

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

From source file:com.doculibre.constellio.wicket.panels.results.DefaultSearchResultPanel.java

License:Open Source License

public DefaultSearchResultPanel(String id, SolrDocument doc, final SearchResultsDataProvider dataProvider) {
    super(id);/* w  w  w .  jav a2  s  .  c o m*/

    RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
    RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
    SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils
            .getSearchInterfaceConfigServices();

    String collectionName = dataProvider.getSimpleSearch().getCollectionName();

    RecordCollection collection = collectionServices.get(collectionName);
    Record record = recordServices.get(doc);
    if (record != null) {
        SearchInterfaceConfig searchInterfaceConfig = searchInterfaceConfigServices.get();

        IndexField uniqueKeyField = collection.getUniqueKeyIndexField();
        IndexField defaultSearchField = collection.getDefaultSearchIndexField();
        IndexField urlField = collection.getUrlIndexField();
        IndexField titleField = collection.getTitleIndexField();

        if (urlField == null) {
            urlField = uniqueKeyField;
        }
        if (titleField == null) {
            titleField = urlField;
        }

        final String recordURL = record.getUrl();
        final String displayURL;

        if (record.getDisplayUrl().startsWith("/get?file=")) {
            HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest();
            displayURL = ContextUrlUtils.getContextUrl(req) + record.getDisplayUrl();

        } else {
            displayURL = record.getDisplayUrl();
        }

        String title = record.getDisplayTitle();

        final String protocol = StringUtils.substringBefore(displayURL, ":");
        boolean linkEnabled = isLinkEnabled(protocol);

        // rcupration des champs highlight  partir de la cl unique
        // du document, dans le cas de Nutch c'est l'URL
        QueryResponse response = dataProvider.getQueryResponse();
        Map<String, Map<String, List<String>>> highlighting = response.getHighlighting();
        Map<String, List<String>> fieldsHighlighting = highlighting.get(recordURL);

        String titleHighlight = getTitleFromHighlight(titleField.getName(), fieldsHighlighting);
        if (titleHighlight != null) {
            title = titleHighlight;
        }

        String excerpt = null;
        String description = getDescription(record);
        String summary = getSummary(record);

        if (StringUtils.isNotBlank(description) && searchInterfaceConfig.isDescriptionAsExcerpt()) {
            excerpt = description;
        } else {
            excerpt = getExcerptFromHighlight(defaultSearchField.getName(), fieldsHighlighting);
            if (excerpt == null) {
                excerpt = description;
            }
        }

        toggleSummaryLink = new WebMarkupContainer("toggleSummaryLink");
        add(toggleSummaryLink);
        toggleSummaryLink.setVisible(StringUtils.isNotBlank(summary));
        toggleSummaryLink.add(new AttributeModifier("onclick", new LoadableDetachableModel() {
            @Override
            protected Object load() {
                return "toggleSearchResultSummary('" + summaryLabel.getMarkupId() + "')";
            }
        }));

        summaryLabel = new Label("summary", summary);
        add(summaryLabel);
        summaryLabel.setOutputMarkupId(true);
        summaryLabel.setVisible(StringUtils.isNotBlank(summary));

        ExternalLink titleLink;
        if (displayURL.startsWith("file://")) {
            HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest();
            String newDisplayURL = ContextUrlUtils.getContextUrl(req) + "app/getSmbFile?"
                    + SmbServletPage.RECORD_ID + "=" + record.getId() + "&" + SmbServletPage.COLLECTION + "="
                    + collectionName;
            titleLink = new ExternalLink("titleLink", newDisplayURL);
        } else {
            titleLink = new ExternalLink("titleLink", displayURL);
        }

        final RecordModel recordModel = new RecordModel(record);
        AttributeModifier computeClickAttributeModifier = new AttributeModifier("onmousedown", true,
                new LoadableDetachableModel() {
                    @Override
                    protected Object load() {
                        Record record = recordModel.getObject();
                        SimpleSearch simpleSearch = dataProvider.getSimpleSearch();
                        WebRequest webRequest = (WebRequest) RequestCycle.get().getRequest();
                        HttpServletRequest httpRequest = webRequest.getHttpServletRequest();
                        return ComputeSearchResultClickServlet.getCallbackJavascript(httpRequest, simpleSearch,
                                record);
                    }
                });
        titleLink.add(computeClickAttributeModifier);
        titleLink.setEnabled(linkEnabled);

        boolean resultsInNewWindow;
        PageParameters params = RequestCycle.get().getPageParameters();
        if (params != null && params.getString(POPUP_LINK) != null) {
            resultsInNewWindow = params.getBoolean(POPUP_LINK);
        } else {
            resultsInNewWindow = searchInterfaceConfig.isResultsInNewWindow();
        }
        titleLink.add(new SimpleAttributeModifier("target", resultsInNewWindow ? "_blank" : "_self"));

        // Add title
        title = StringUtils.remove(title, "\n");
        title = StringUtils.remove(title, "\r");
        if (StringUtils.isEmpty(title)) {
            title = StringUtils.defaultString(displayURL);
            title = StringUtils.substringAfterLast(title, "/");
            title = StringUtils.substringBefore(title, "?");
            try {
                title = URLDecoder.decode(title, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (title.length() > 120) {
                title = title.substring(0, 120) + " ...";
            }
        }

        Label titleLabel = new Label("title", title);
        titleLink.add(titleLabel.setEscapeModelStrings(false));
        add(titleLink);

        Label excerptLabel = new Label("excerpt", excerpt);
        add(excerptLabel.setEscapeModelStrings(false));
        // add(new ExternalLink("url", url,
        // url).add(computeClickAttributeModifier).setEnabled(linkEnabled));
        if (displayURL.startsWith("file://")) {
            // Creates a Windows path for file URLs
            String urlLabel = StringUtils.substringAfter(displayURL, "file:");
            urlLabel = StringUtils.stripStart(urlLabel, "/");
            urlLabel = "\\\\" + StringUtils.replace(urlLabel, "/", "\\");
            try {
                urlLabel = URLDecoder.decode(urlLabel, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            add(new Label("url", urlLabel));
        } else {
            add(new Label("url", displayURL));
        }

        final ReloadableEntityModel<RecordCollection> collectionModel = new ReloadableEntityModel<RecordCollection>(
                collection);
        add(new ListView("searchResultFields", new LoadableDetachableModel() {
            @Override
            protected Object load() {
                RecordCollection collection = collectionModel.getObject();
                return collection.getSearchResultFields();
            }

            /**
             * Detaches from the current request. Implement this method with
             * custom behavior, such as setting the model object to null.
             */
            protected void onDetach() {
                recordModel.detach();
                collectionModel.detach();
            }
        }) {
            @Override
            protected void populateItem(ListItem item) {
                SearchResultField searchResultField = (SearchResultField) item.getModelObject();
                IndexFieldServices indexFieldServices = ConstellioSpringUtils.getIndexFieldServices();
                Record record = recordModel.getObject();
                IndexField indexField = searchResultField.getIndexField();
                Locale locale = getLocale();
                String indexFieldTitle = indexField.getTitle(locale);
                if (StringUtils.isBlank(indexFieldTitle)) {
                    indexFieldTitle = indexField.getName();
                }
                StringBuffer fieldValueSb = new StringBuffer();
                List<Object> fieldValues = indexFieldServices.extractFieldValues(record, indexField);
                Map<String, String> defaultLabelledValues = indexFieldServices
                        .getDefaultLabelledValues(indexField, locale);
                for (Object fieldValue : fieldValues) {
                    if (fieldValueSb.length() > 0) {
                        fieldValueSb.append("\n");
                    }
                    String fieldValueLabel = indexField.getLabelledValue("" + fieldValue, locale);
                    if (fieldValueLabel == null) {
                        fieldValueLabel = defaultLabelledValues.get("" + fieldValue);
                    }
                    if (fieldValueLabel == null) {
                        fieldValueLabel = "" + fieldValue;
                    }
                    fieldValueSb.append(fieldValueLabel);
                }

                item.add(new Label("indexField", indexFieldTitle));
                item.add(new MultiLineLabel("indexFieldValue", fieldValueSb.toString()));
                item.setVisible(fieldValueSb.length() > 0);
            }

            @SuppressWarnings("unchecked")
            @Override
            public boolean isVisible() {
                boolean visible = super.isVisible();
                if (visible) {
                    List<SearchResultField> searchResultFields = (List<SearchResultField>) getModelObject();
                    visible = !searchResultFields.isEmpty();
                }
                return visible;
            }
        });

        // md5
        ConstellioSession session = ConstellioSession.get();
        ConstellioUser user = session.getUser();
        // TODO Provide access to unauthenticated users ?
        String md5 = "";
        if (user != null) {
            IntelliGIDServiceInfo intelligidServiceInfo = ConstellioSpringUtils.getIntelliGIDServiceInfo();
            if (intelligidServiceInfo != null) {
                Collection<Object> md5Coll = doc.getFieldValues(IndexField.MD5);
                if (md5Coll != null) {
                    for (Object md5Obj : md5Coll) {
                        try {
                            String md5Str = new String(Hex.encodeHex(Base64.decodeBase64(md5Obj.toString())));
                            InputStream is = HttpClientHelper
                                    .get(intelligidServiceInfo.getIntelligidUrl() + "/connector/checksum",
                                            "md5=" + URLEncoder.encode(md5Str, "ISO-8859-1"),
                                            "username=" + URLEncoder.encode(user.getUsername(), "ISO-8859-1"),
                                            "password=" + URLEncoder.encode(Base64.encodeBase64String(
                                                    ConstellioSession.get().getPassword().getBytes())),
                                            "ISO-8859-1");
                            try {
                                Document xmlDocument = new SAXReader().read(is);
                                Element root = xmlDocument.getRootElement();
                                for (Iterator<Element> it = root.elementIterator("fichier"); it.hasNext();) {
                                    Element fichier = it.next();
                                    String url = fichier.attributeValue("url");
                                    md5 += "<a href=\"" + url + "\">" + url + "</a> ";
                                }
                            } finally {
                                IOUtils.closeQuietly(is);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
        Label md5Label = new Label("md5", md5) {
            public boolean isVisible() {
                boolean visible = super.isVisible();
                if (visible) {
                    visible = StringUtils.isNotBlank(this.getModelObjectAsString());
                }
                return visible;
            }
        };
        md5Label.setEscapeModelStrings(false);
        add(md5Label);

        add(new ElevatePanel("elevatePanel", record, dataProvider.getSimpleSearch()));
    } else {
        setVisible(false);
    }
}

From source file:com.example.justaddwater.components.LoginForm.java

License:Apache License

public LoginForm(String id) {
    super(id);//w w  w.  j av  a 2  s  . c om

    add(new TextField("username").setRequired(true));
    add(new PasswordTextField("password").setRequired(true));
    add(new ExternalLink("loginWithFacebook", FacebookOAuthPage.getFacebookLoginUrl()));
}

From source file:com.example.justaddwater.web.app.SignupPage.java

License:Apache License

public SignupPage(final PageParameters parameters) {
    super(parameters);
    add(new Header("header"));

    Form form = new Form("form");
    form.setOutputMarkupId(true);//from  w ww. j  a v  a  2s .  c om

    feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);
    form.add(feedback);

    form.add(new ExternalLink("fbLink", FacebookOAuthPage.getFacebookLoginUrl()));

    usernameField = new RequiredTextField<String>("username", new Model<String>());
    passwordField = new PasswordTextField("password", new Model<String>());
    passwordField.setRequired(true);
    passwordField.add(StringValidator.lengthBetween(6, 32));

    confirmPasswordField = new PasswordTextField("password-confirm", new Model<String>());
    confirmPasswordField.setRequired(true);

    form.add(usernameField);
    form.add(passwordField);
    form.add(confirmPasswordField);

    form.add(new EqualPasswordInputValidator(passwordField, confirmPasswordField));

    AjaxButton submit = new AjaxButton("submit") {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            String username = usernameField.getModelObject();
            String pw = passwordField.getModelObject();

            User existingUser = dao.findUserByEmail(username);
            if (existingUser != null) {
                usernameField.error("a user with that username already exists, account type: "
                        + existingUser.getAuthenticationType());
                target.add(form);
            } else {
                User user = new User();
                createAccount(user, username, pw);
                setResponsePage(new AccountPage());
            }
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(feedback);
            target.add(form);
        }

    };
    form.add(submit);

    add(form);
}