Here is the complete (test) code
============ SOLUTION 1 : wicket:container ============= ++++ TestPage.html ++++ <html> <body> <div class="products"> <wicket:container wicket:id="products"> <div wicket:id="product" class="product"></div> </wicket:container> </div> </body> </html> ++++ TestPage.java ++++ import java.util.Arrays; import java.util.List; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.list.ListItem; import org.apache.wicket.markup.html.list.ListView; public class TestPage extends WebPage { public TestPage() { List products = Arrays.asList("productA", "productB", "productC"); ListView productsView = new ListView("products", products) { protected void populateItem(ListItem item) { String product = (String) item.getModelObject(); item.add(new Label("product", product)); } }; add(productsView); } } ============== SOLUTION 2 : extra div in WicketHTML ================== ++++ TestPage.html ++++ <html> <body> <div class="products"> <div wicket:id="products"> <div wicket:id="product" class="product"></div> </div> </div> </body> </html> ++++ TestPage.java ++++ import java.util.Arrays; import java.util.List; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.list.ListItem; import org.apache.wicket.markup.html.list.ListView; public class TestPage extends WebPage { public TestPage() { List products = Arrays.asList("productA", "productB", "productC"); ListView productsView = new ListView("products", products) { protected void populateItem(ListItem item) { String product = (String) item.getModelObject(); item.add(new Label("product", product)); item.setRenderBodyOnly(true); } }; add(productsView); } } ==== Wanted/Required and generated output of solution1 & 2 === <html> <body> <div class="products"> <div class="product">productA</div> <div class="product">productB</div> <div class="product">productC</div> </div> </body> </html> ========================================================== For this common scenario: -solution 1 violates Wickets "Just HTML" philosophy in that the wicket:container tag is used. -solution 2 violates Wickets "Just HTML" philosophy in that an extra unwanted div is required in WicketHTML (although not visible in the generated HTML). No other solutions have been found/discussed yet. > ----- Original Message ----- > From: Fatih Mehmet UCAR > Sent: 08/21/10 05:02 PM > To: users@wicket.apache.org > Subject: Re: setRenderBodyOnly with ListView and attributes > > send your html and java code, there may be other ways of doing this. > > > ----- Original Message ----- > From: "J" <bluecar...@gmx.com> > To: <users@wicket.apache.org> > Sent: Saturday, August 21, 2010 3:29 PM > Subject: Re: setRenderBodyOnly with ListView and attributes > > > >I made a mistake in my first post. The output of wasn't: > > > > <div> > > <div class="product">.....</div> > > <div class="product">.....</div> > > <div class="product">.....</div> > > <div class="product">.....</div> > > </div> > > > > but it was: > > <div class="product">.....</div> > > <div class="product">.....</div> > > <div class="product">.....</div> > > <div class="product">.....</div> > > > > So the outer div is missing. > > Which is caused by item.setRenderBodyOnly(true). But if I disable (set to > > false) this (the default), I get: > > > > <div class="products"><div class="product">.....</div></div> > > <div class="products"><div class="product">.....</div></div> > > <div class="products"><div class="product">.....</div></div> > > <div class="products"><div class="product">.....</div></div> > > > > which is even worse. > > > > A solution (the only?) to this double div problem and at the same time the > > missing attribute problem, is using wicket:container tags. (see > > http://apache-wicket.1842946.n4.nabble.com/Panel-in-List-remove-extra-div-td1877053.html > > ) > > This leads to this solution: > > > > > > <div class="products"> > > <wicket:container wicket:id="products"> > > <div class="product" wicket:id="productPanel">.....</div> > > </wicket:container> > > </div> > > > > Wicket:container tags make it ugly imo, because it violates wickts "just > > HTML" philosophy, even though my problem is a very common scenario. > > > > > >> ----- Original Message ----- > >> From: Fatih Mehmet UCAR > >> Sent: 08/21/10 04:05 PM > >> To: users@wicket.apache.org > >> Subject: Re: setRenderBodyOnly with ListView and attributes > >> > >> Add another html div with css class you want around the below list div ; > >> > >> <div class="products" wicket:id="productsView"> > >> > >> and for the productsViev in the java code setRenderBodyOnly to true. > >> > >> -fmu > >> > >> > >> ----- Original Message ----- > >> From: "J" <bluecar...@gmx.com> > >> To: <users@wicket.apache.org> > >> Sent: Saturday, August 21, 2010 2:49 PM > >> Subject: Re: setRenderBodyOnly with ListView and attributes > >> > >> > >> > It somehow feels bad/wrong to move CSS from WicketHTML to JavaCode, > >> > where > >> > it shouldn't belong, for such a common scenario. > >> > It defeats the purpose of having HTML in Wicket. But there probably is > >> > no > >> > other way. > >> > > >> > Anyway, thanks for your reply :) > >> > > >> > > >> >> ----- Original Message ----- > >> >> > >> >> From: Fatih Mehmet UCAR > >> >> Sent: 08/21/10 03:43 PM > >> >> To: users@wicket.apache.org > >> >> Subject: Re: setRenderBodyOnly with ListView and attributes > >> >> > >> >> AttributeAppender class will help you to acheive that. > >> >> > >> >> -fmu > >> >> > >> >> ----- Original Message ----- > >> >> From: "J" <bluecar...@gmx.com> > >> >> To: <users@wicket.apache.org> > >> >> Sent: Saturday, August 21, 2010 2:24 PM > >> >> Subject: setRenderBodyOnly with ListView and attributes > >> >> > >> >> > >> >> > hi, I want to have Wicket to generate the following HTML precisely: > >> >> > > >> >> > <div class="products"> > >> >> > <div class="product">.....</div> > >> >> > <div class="product">.....</div> > >> >> > <div class="product">.....</div> > >> >> > <div class="product">.....</div> > >> >> > </div> > >> >> > > >> >> > But with my code, I don't get further than: > >> >> > > >> >> > <div> > >> >> > <div class="product">.....</div> > >> >> > <div class="product">.....</div> > >> >> > <div class="product">.....</div> > >> >> > <div class="product">.....</div> > >> >> > </div> > >> >> > > >> >> > so the class attribute is missing in the outer div. > >> >> > > >> >> > My Wicket HTML is: > >> >> > <div class="products" wicket:id="productsView"> > >> >> > <div class="product" wicket:id="productPanel">.....</div> > >> >> > </div> > >> >> > > >> >> > > >> >> > My code: > >> >> > ListView productsView = new ListView("productsView", products) { > >> >> > protected void populateItem(ListItem item) { > >> >> > item.setRenderBodyOnly(true); > >> >> > item.add(new ProductPanel("productPanel", item.getModelObject())); > >> >> > } > >> >> > }; > >> >> > add(productsView); > >> >> > > >> >> > > >> >> > What is the Wicket way of achieving this? > >> >> > (A solution is to use the wicket:container tag, but that's a bit > >> >> > ugly, > >> >> > right?) > >> >> > > >> >> > --------------------------------------------------------------------- > >> >> > 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 > >> > > >> > --------------------------------------------------------------------- > >> > 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 > > > > --------------------------------------------------------------------- > > 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 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org