You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Graham O'Regan <gr...@gmail.com> on 2007/07/31 20:06:13 UTC

unordered list as navigation

I've seen references to similar questions around but I haven't been able 
to find a clean solution to this problem. I want to be able to create a 
panel that accepts labels and links so the html looks like this;

<wicket:panel>
            <ul wicket:id="optionalNavigation">
                <li>
                    <a wicket:id="optionalLink"><span 
wicket:id="optionalLabel">[replace]</span></a>
                </li>
            </ul>
        </wicket:panel>

I [think I] need the "optionalLabel" because I want to specify the label 
that is displayed, not the value that is generated from <a 
wicket:id="optionalLink">. I've got a solution that accepts a Link("") 
and then delegates to it's onClick() so I can specify the name I need 
for the template, but it doesn't feel like the correct solution.

So, 2 questions;

1. Is there an existing component that I could use (can't find anything 
so far)
2. Is there a way I could do something like this;

UnorderedList nav = new UnorderedList("nav");
nav.addItem(new ListItem("name", new Label("optionalLabel",new 
Model("could be anything")),new Link("optionalLink"){..});
add(nav);

Apologies if this has been answered before, I can't find a cleaner 
solution than the one I have but it seems like a basic requirement that 
a lot of people must have solved.

TIA

Graham

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: unordered list as navigation

Posted by Igor Vaynberg <ig...@gmail.com>.
interface menuitem {
  IModel getLabel(); // can be null
  void onClick(); // onclick handler
}

list<menuitem> items=....
add(new navigationpanel("panel", items));

-igor



On 7/31/07, Graham O'Regan <gr...@gmail.com> wrote:
>
> I've seen references to similar questions around but I haven't been able
> to find a clean solution to this problem. I want to be able to create a
> panel that accepts labels and links so the html looks like this;
>
> <wicket:panel>
>             <ul wicket:id="optionalNavigation">
>                 <li>
>                     <a wicket:id="optionalLink"><span
> wicket:id="optionalLabel">[replace]</span></a>
>                 </li>
>             </ul>
>         </wicket:panel>
>
> I [think I] need the "optionalLabel" because I want to specify the label
> that is displayed, not the value that is generated from <a
> wicket:id="optionalLink">. I've got a solution that accepts a Link("")
> and then delegates to it's onClick() so I can specify the name I need
> for the template, but it doesn't feel like the correct solution.
>
> So, 2 questions;
>
> 1. Is there an existing component that I could use (can't find anything
> so far)
> 2. Is there a way I could do something like this;
>
> UnorderedList nav = new UnorderedList("nav");
> nav.addItem(new ListItem("name", new Label("optionalLabel",new
> Model("could be anything")),new Link("optionalLink"){..});
> add(nav);
>
> Apologies if this has been answered before, I can't find a cleaner
> solution than the one I have but it seems like a basic requirement that
> a lot of people must have solved.
>
> TIA
>
> Graham
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>