Hello to all,

i am trying to build a dynamic menu based on data from a database. So i thought i could build it like my code shows it. To highlight the selected menu i try to dynamically add an attribute to the li tag in the onClick method. I would also want to load and repaint other panels (for example loading sub menus ), when the user clicks a menu link. But it is not working. What am i doing wrong?

<pre>
ListView<Menu> lv = new ListView<Menu>("mainMenu", menuList) {
                @Override
                protected void populateItem(final ListItem<Menu> item) {
                    Menu menuItem = (Menu) item.getModelObject();
                    Link<Menu> link = new Link<Menu>("menuLink") {
                        @Override
                        public void onClick() {
item.add(new AttributeAppender("id", new Model("current_menu"), ";")); System.out.println("item was clicked " + item.getPath());
                        }

                    };
link.add(new Label("menuCaption", menuItem.getMenuNameDe()));
                    item.add(link);
                }
            };
            add(lv);
</pre>

and this is my panel markup:

<pre>
<body>
<wicket:panel>
<ul>
<li wicket:id="mainMenu">
<a href="#" wicket:id="menuLink"><span wicket:id="menuCaption"></span></a>
</li>
</ul>
</wicket:panel>
</body>
</pre>
My goal:

<pre>
<body>
<wicket:panel>
<ul>
<li wicket:id="mainMenu" id="current_menu">
<a href="#" wicket:id="menuLink"><span wicket:id="menuCaption"></span></a>
</li>
</ul>
</wicket:panel>
</body>
</pre>

Thank you for any help!


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

Reply via email to