First of all, avoid using a label to generate html. Put the repeater on the
LI element and add a link. Looks like you want an ExternalLink.

HTML
------------------------------
>
> -----------
> <ul>
>        <li>
>                <a href="#">First static item</a>
>        </li>
>        <li>
>                <a href="#">Second static item</a>
>        </li>
>        <li wicket:id="dynamicItems">
>                <a wicket:id="dynamicListItem"></a>
>        </li>
> </ul>
>
> Code
> -----------------------------------------
> ListView dynamicItems = new ListView("dynamicItems", someList) {
>        protected void populateItem(ListItem item) {
>                ExternalLink link = new ExternalLink("dynamicListItem",
> "hrefDestination" ,item.getModel());
>                item.add(link);
>        }
> };


You end up with better markup and java that is clearer to understand.





On Sun, Apr 17, 2011 at 8:14 AM, Alexandros Karypidis <akary...@yahoo.gr>wrote:

> Hello,
>
> I have a page with a simple HTML unordered list (<ul>), where part of the
> list items are static, whereas the rest of them are dynamic. To that end,
> I've injected a <span> tag at the end of the static items, adding a ListView
> in order to fill in the "dynamic" part, as follows:
>
> HTML
> -----------------------------------------
> <ul>
>        <li>
>                <a href="#">First static item</a>
>        </li>
>        <li>
>                <a href="#">Second static item</a>
>        </li>
>        <span wicket:id="dynamicItems">
>                <li wicket:id="dynamicListItem"></li>
>        </span>
> </ul>
>
> Code
> -----------------------------------------
> ListView dynamicItems = new ListView("dynamicItems", someList) {
>        protected void populateItem(ListItem item) {
>                Label link = new Label("dynamicListItem",
>                        "<a href='...'>" + item.getModelObject() + "</a>");
>                link.setEscapeModelStrings(false);
>                item.add(link);
>        }
> };
>
> This achieves what I need, but keeps the <span> tags in place (causing some
> unrelated CSS to miss its target elements). So, the HTML that is produced is
> as follows...:
>
> <ul>
>        <li>
>                <a href="#">First static item</a>
>        </li>
>        <li>
>                <a href="#">Second static item</a>
>        </li>
>        <span><li>First dynamic item</li></span>
>        <span><li>Second dynamic item</li></span>
>        <span><li>Third dynamic item</li></span>
> </ul>
>
> But what I want to achieve is the following "clean" output (notice the
> absence of <span> tags):
>
> <ul>
>        <li>
>                <a href="#">First static item</a>
>        </li>
>        <li>
>                <a href="#">Second static item</a>
>        </li>
>        <li>First dynamic item</li>
>        <li>Second dynamic item</li>
>        <li>Third dynamic item</li>
> </ul>
>
> How can I achieve this?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to