ItemPanel(String, MenuRow) is called by newItemPanel(String, MenuRow) is called by populateItem(ListItem). Populate item looks like this:
protected void populateItem(ListItem item) { final MenuItem menuItem = (MenuItem)item.getModelObject(); final Panel itemPanel = menuItem.newItemPanel("itemPanel", MenuRow.this); if (itemPanel == null) { throw new WicketRuntimeException("item panel must be not-null"); } if (!"itemPanel".equals(itemPanel.getId())) { throw new WicketRuntimeException("item panel must have id 'itemPanel' assigned"); } itemPanel.setRenderBodyOnly(true); item.add(itemPanel); } The problem with that code is this line: itemPanel.setRenderBodyOnly(true); that should be itemPanel.setRenderBodyOnly(false); or be removed to have any attribute modifier work (as with true, there is no attribute as there is no tag). Thanks for finding that bug, and sorry that you spent a lot of time on it. Cheers, Eelco On 2/21/06, Mats Norén <[EMAIL PROTECTED]> wrote: > This code is taken from the wicket-contrib-navmenu. It defines a > wicket:panel for the menuitems. > I'm having real trouble with the AttributeModifier. > Looking at the code the AttributeModifier is attached to the panel itself. > > public ItemPanel(final String id, final MenuRow row) > { > super(id); > final String label = getLabel(); > final BookmarkablePageLink pageLink = new > BookmarkablePageLink("link", getPageClass(), > getPageParameters()); > pageLink.setAutoEnable(false); > pageLink.add(new Label("label", label)); > add(pageLink); > add(new AttributeModifier("class", true, new Model() > { > public Object getObject(final Component component) > { > return > row.getRowStyle().getItemCSSClass(MenuItem.this, row); > } > })); > } > > The HTML code for the panel is: > > <wicket:panel><a wicket:id="link" href="#"><span wicket:id="label">the > label</span></a></wicket:panel> > > The panel itself is used from the following code: > > <wicket:panel> > > <div wicket:id="div"> > <ul wicket:id="ul"> > <li wicket:id="columns"><span wicket:id="itemPanel"><a > href="#">label here</a></span> > </li> > </ul> > </div> > > </wicket:panel> > > Looking in the css the class "tabSelected" referenced from the code is > applied to an <li> which to me indicates that the AttributeModifier is > attached to the <li>. > However the getObject-method of the Model is never called. And the > resulting HTML doesn't contain any class-attribute. > > I've been looking at the code for two days now and I'm certain that > I've overlooked something but I don't now what... > > Would appreciate another pair of eyes on it... > > I'm running wicket 1.2 CVS from friday last week. > > /Mats > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://sel.as-us.falkag.net/sel?cmdlnk&kid3432&bid#0486&dat1642 > _______________________________________________ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user > ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642 _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user