Hi Kuga,

ListView re-creates all its child items on each render, which might be
causing your problems. Try calling setReuseItems(true), or better still,
consider using RepeatingView instead.

jk

On Fri, Jul 31, 2009 at 11:30:57PM -0700, Kuga wrote:
> 
> Hi,
> Thank you for your response,
> here is the ListView code:
> private final class SubMenuListView extends ListView {
>         private static final long serialVersionUID = 0L;
> 
>         private int selectedIndex = 0;
>         
>         private SubMenuListView(final String id, final IModel model) {
>             super(id, model);
>         }
> 
>         private SubMenuListView(final String id, final List<MenuItem> list)
> {
>             super(id, list);
>         }
>         
>         /* (non-Javadoc)
>                * @see org.apache.wicket.markup.html.list.ListView#newItem(int)
>                */
>               @Override
>               protected ListItem newItem(int index) {
>                       // TODO Auto-generated method stub
>                       return new ListItem(index, getListItemModel(getModel(), 
> index)){
> 
>                               /* (non-Javadoc)
>                                * @see
> org.apache.wicket.Component#onComponentTag(org.apache.wicket.markup.ComponentTag)
>                                */
>                               @Override
>                               protected void onComponentTag(ComponentTag tag) 
> {                                       
>                                       String cssClass = 
> (String)tag.getString("class"); //$NON-NLS-1$
>                                       if (cssClass == null)
>                                       {
>                                               cssClass = " "; //$NON-NLS-1$
>                                       }                               
>                                       if 
> (((MenuItem)getModelObject()).isSelected())
>                                       {
>                                               cssClass = 
> "menu2-selected-long"; //$NON-NLS-1$
>                                       } else{
>                                               cssClass = " "; //$NON-NLS-1$
>                                       }
>                                       tag.put("class", cssClass.trim()); 
> //$NON-NLS-1$
>                                       super.onComponentTag(tag);
>                               }
>                               
>                       };
>               }
> 
>               @Override
>         protected void populateItem(final ListItem item) {
>             final MenuItem menuItem = (MenuItem) item.getModelObject();
>             if (menuItem.isSelected()) {
>                 if(menuLevel.equals(MenuLevel.TOP)) {
>                     item.add(menuIsSelected); //set CSS class if the
> top-level menu item is selected
>                 }
>                 else if(menuLevel.equals(MenuLevel.SECOND)) {
>                     item.add(menuIsSelectedLong); //set CSS class if the
> second-level menu item is selected
>                 }
>             }
>             item.add(new MenuItemFragment(menuItem));
>         }
> 
>               /**
>                * @param selectedIndex the selectedIndex to set
>                */
>               public void setSelectedIndex(int selectedIndex) {
>                       this.selectedIndex = selectedIndex;
>               }
> 
>               /**
>                * @return the selectedIndex
>                */
>               public int getSelectedIndex() {
>                       return selectedIndex;
>               }
>     }
> -- 
> View this message in context: 
> http://www.nabble.com/Issue-with-AjaxLinks-in-ListView-tp24765587p24766483.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 

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

Reply via email to