Here is my code that works for me. I put the navigation bar in a panel.

<wicket:panel>
   <span wicket:id="mainNavList">
     <span wicket:id="navigationItem" >
       <a href="#">
         <span wicket:id="navigationLabel"></span>
       </a>
     </span>
   </span>

</wicket:panel>

And the java class looks like this:

public class MainMenuListView extends ListView<INavigationItem> {

   private static final long serialVersionUID = 1L;
protected static Logger logger = Logger.getLogger(MainMenuListView.class); public MainMenuListView(String id, List<INavigationItem> dataList) {
       super(id, dataList);
   }
@Override
   protected void populateItem(ListItem item) {
       INavigationItem navItem = (INavigationItem) item.getModelObject();
       ResourceModel rModel = new ResourceModel(navItem.getResourceKey());
BookmarkablePageLink pageLink = new BookmarkablePageLink("navigationItem", navItem.getNavTargetClass()); item.add(new BookmarkablePageLink("navigationItem", navItem.getNavTargetClass()).add(new Label("navigationLabel", rModel)));
   }

}


Alexander Landsnes Keül wrote:
They need the same wicket:id yes, but that doesn't mean that they need the same 
text or targets. Just create as many links as you want/need, with whatever 
behaviour they need. Just make sure they all have the same id :)

Alex

-----Opprinnelig melding-----
Fra: Edbay [mailto:[EMAIL PROTECTED] Sendt: 22. juli 2008 19:00
Til: users@wicket.apache.org
Emne: RE: How to build a dynamic navigation bar


Thanks for the quick reply.

Wouldn't this force all links to have the same wicket ids ("linkid")?
I'd like to be able to have the line items look like this:

<ul wicket:id="list">
        <li> # Link01 text here </li>
        <li> # Link02 text here </li>
        <li> # Link03 text here </li>
</ul>





Alexander Landsnes Keül wrote:
I'd use a ListView :)

Assuming this lil code

add( new ListView("list", linkList )
{
        public void populateItem(ListItem item)
        {
                item.add( (Link)linkList );
        }
});

You'd have the html look something like this

<ul wicket:id="list">
        <li> # Link text here </li>
</ul>

Just remember to add whatever you want to the item, and not just use
add(...).
http://wicket.apache.org/docs/wicket-1.3.2/wicket/apidocs/org/apache/wicket/markup/html/list/ListView.html

Alex

-----Opprinnelig melding-----
Fra: Edbay [mailto:[EMAIL PROTECTED] Sendt: 22. juli 2008 18:08
Til: users@wicket.apache.org
Emne: How to build a dynamic navigation bar


Hello, I want to be able to build a left-side dynamic navigation bar based on
user
permissions. For example, if the user does not have access to the Prices
page, I do not want to show the Prices link on the navigation bar. Also,
since the link will point to a Wicket page, it has to be a Wicket link. This is how I would like the NavBar to appear:
                <div id="mainNav">
                        <ul>
                                <li> Home </li>
                                <li> Prices </li>
                                <li> Contracts </li>
                                <li> Products </li>
                                <li> Transactions </li>
                        </ul>
                </div>

I tried using ListView, but I could not get it to work, as it forces the
wicket id of the line items to be all the same.

Thanks in advance.
--
View this message in context:
http://www.nabble.com/How-to-build-a-dynamic-navigation-bar-tp18592899p18592899.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to