Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>ExternalLink</code> takes a model parameter that supplies a link URL. That model can be pretty much anything. Here's one that generates random links (<code>LoadableDetachableModel</code> is a convenience implementation of a dynamic model):</p> <pre><code>IModel&lt;String&gt; model=new LoadableDetachableModel&lt;String&gt;() { private static final long serialVersionUID = 1L; @Override protected String load() { // this class does not really exist return LinkRandomizer.getNewRandomUrl(); } }; add(new ExternalLink("link", model)); </code></pre> <p>See:</p> <ul> <li><a href="https://cwiki.apache.org/WICKET/working-with-wicket-models.html" rel="nofollow noreferrer">Working with Wicket Models</a></li> <li><a href="http://www.javaranch.com/journal/2008/10/using-wicket-labels-and-links.html" rel="nofollow noreferrer">Using Wicket Labels and Links</a></li> <li><a href="http://wicket.apache.org/apidocs/1.4/org/apache/wicket/markup/html/link/ExternalLink.html" rel="nofollow noreferrer">ExternalLink API docs</a></li> <li><a href="http://wicket.apache.org/apidocs/1.4/org/apache/wicket/model/LoadableDetachableModel.html" rel="nofollow noreferrer">LoadableDetachableModel API docs</a></li> </ul> <hr> <p>It turns out the OP needs a <code>ListView</code> with <code>ExternalLink</code>s.</p> <p>Here is a Panel with a list of links:</p> <pre><code>public class FooPanel extends Panel { private static final long serialVersionUID = 1L; public static class LinkBean{ private String link; private String label; public LinkBean(final String link, final String label) { this.link = link; this.label = label; } public String getLabel() { return this.label; } public String getLink() { return this.link; } public void setLabel(final String label) { this.label = label; } public void setLink(final String link) { this.link = link; } } public FooPanel(final String id) { super(id); this.add(new ListView&lt;LinkBean&gt;("item", Arrays.asList( new LinkBean("http://www.google.com/","Google"), new LinkBean("http://www.ebay.com/", "Ebay")) ) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem&lt;LinkBean&gt; item) { item.add(new ExternalLink("link", item.getModelObject().getLink()) .add(new Label("label",item.getModelObject().getLabel())) ); } }); } } </code></pre> <p>And here is the associated HTML:</p> <pre><code>&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt; &lt;wicket:panel&gt; &lt;div class="linkItem" wicket:id="item"&gt; &lt;a href="" wicket:id="link" &gt; &lt;wicket:container wicket:id="label" /&gt; &lt;/a&gt; &lt;/div&gt; &lt;/wicket:panel&gt; &lt;/body&gt;&lt;/html&gt; </code></pre> <p>The Output will be something like this:</p> <pre><code>&lt;div class="linkItem"&gt;&lt;a href="http://www.google.com/"&gt;Google&lt;/a&gt;&lt;/div&gt; &lt;div class="linkItem"&gt;&lt;a href="http://www.ebay.com/"&gt;Ebay&lt;/a&gt;&lt;/div&gt; </code></pre> <p>See</p> <ul> <li><a href="https://cwiki.apache.org/WICKET/listview-and-other-repeaters.html" rel="nofollow noreferrer">ListView and other repeaters</a> (an ancient tutorial, careful: this relates to the older non-generic version of ListView in 1.3.x)</li> <li><a href="http://wicketstuff.org/wicket14/repeater/" rel="nofollow noreferrer">Wicket Examples: Repeater Views</a> (ListView is not covered, but the handling is pretty identical)</li> <li><a href="http://wicket.apache.org/apidocs/1.4/org/apache/wicket/markup/html/list/ListView.html" rel="nofollow noreferrer">ListView Api docs</a></li> <li><a href="http://www.manning.com/dashorst/" rel="nofollow noreferrer">Wicket in Action</a> (A very good book about Wicket you should consider buying)</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload