Short answer is in ListView's javadoc:

 * <p>
 * <strong>NOTE:</strong>
 *
* When you want to change the default generated markup it is important to realize that the ListView * instance itself does not correspond to any markup, however, the generated ListItems do.<br/>
 *
 * This means that methods like {@link #setRenderBodyOnly(boolean)} and
* {@link #add(org.apache.wicket.behavior.Behavior...)} should be invoked on the {@link ListItem}
 * that is given in {@link #populateItem(ListItem)} method.
 * </p>

Sven

On 02/24/2013 02:40 AM, Gonzalo Aguilar Delgado wrote:
Hello,

I think I found something that may not be working right.

I have an html that looks like:

        <div wicket:id="regionOne">
                <div wicket:id="regionWidget"></div>
        </div>


regionOne will be a listview and regionWidget will be one panel
populated on populateItem.


This is how it looks the class that will go to regionOne (listview)

public class RegionWidgetContainer extends ListView<RegionWidget> {
        /**
         *
         */
        private static final long serialVersionUID = 1L;
        final static Logger logger =
LoggerFactory.getLogger(RegionWidgetContainer.class);
        private static int regionCounter = 1;

        private int regionIdx=0;

        public RegionWidgetContainer(String id, final Region region, PageUser
pageUser) {
                super(id, new IModel<List<RegionWidget>>(){

                        /**
                         *
                         */
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void detach() {
                                // TODO Auto-generated method stub
                        }

                        @Override
                        public List<RegionWidget> getObject() {
                                return region.getRegionWidgets();
                        }

                        @Override
                        public void setObject(List<RegionWidget> object) {
                        }
                        
                });
                regionIdx = RegionWidgetContainer.nextCounter();
                buildCssClassAttributes(region,pageUser);
                this.setMarkupId("region-" + region.getId() + "-id");       
                this.setOutputMarkupId(true);
        }
        
        protected void buildCssClassAttributes(Region region, PageUser
pageUser)
        {
                String cssClass = "region";
                if(region.isLocked() || !pageUser.isEditor())
                {
                        cssClass += " region-locked";
                }
                
                cssClass += " " + region.getPage().getPageLayout().getCode() + 
"_" +
String.valueOf(regionIdx);
                cssClass += " regionNonDragging";
                
                
                this.add(new AttributeAppender("class", cssClass));
        }
...
}



As you can see it will add the class via AttributeAppender and will set
the markup id.


But it does not work. Any of two. The div is rendered like this...

<div>
...
</div>


So, is this a bug or a feature?




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

Reply via email to