You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Prag <pr...@gmail.com> on 2009/01/25 21:19:48 UTC
Panel in List, remove extra div
I have a page on which I want to show products. Because I want to also want
to show products on otherpages in the same way, I've made a ProductPanel.
I'm also using ListView to show multiple ProductPanels on each page.
I'm using a panel in a list, but this gives an extra div. I don't see how I
can remove this extra div.
See my code below and the generated html output. As you can see, every
single item in the list, gives this html: <div wicket:id="products"> and
<div wicket:id="product">. I would like to have only 1 div instead of two.
What is the Wicket way to solve this?
==== ProductsPage.html =====
<div wicket:id="products">
<div wicket:id="product"></div>
</div>
==== ProductsPage.java =====
public class ProductsPage extends BasePage {
public ModelsPage() {
List<Product> products = dao.getProducts();
add(new ListView("products", products) {
@Override
protected void populateItem(ListItem item) {
Product product = (Product) item.getModelObject();
item.add(new ProductPanel("product", product));
}
});
}
}
==== ProductPanel.html =====
<wicket:panel>
</wicket:panel>
==== ProductPanel.java =====
public class ProductPanel extends Panel {
public ProductPanel(String id, Product product) {
super(id);
add(new Label("name", product.getName()));
add(new Label("description", product.getDescription()));
add(new Label("price", product.getPrice()));
}
}
==== Generated HTML Output =====
<div wicket:id="products">
<div wicket:id="product">
<wicket:panel>
aaaa
aaaa
1111
</wicket:panel>
</div>
</div>
<div wicket:id="products">
<div wicket:id="product">
<wicket:panel>
bbbbb
bbbbbb
22222
</wicket:panel>
</div>
</div>
<div wicket:id="products">
<div wicket:id="product">
<wicket:panel>
ccccc
ccccc
33333
</wicket:panel>
</div>
</div>
--
View this message in context: http://www.nabble.com/Panel-in-List%2C-remove-extra-div-tp21656188p21656188.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Panel in List, remove extra div
Posted by Prag <pr...@gmail.com>.
Perfect, thanks!
igor.vaynberg wrote:
>
> <wicket:container wicket:id="products">
> <div wicket:id="product"></div>
> </wicket:container>
>
> -igor
>
--
View this message in context: http://www.nabble.com/Panel-in-List%2C-remove-extra-div-tp21656188p21656303.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Panel in List, remove extra div
Posted by Igor Vaynberg <ig...@gmail.com>.
<wicket:container wicket:id="products">
<div wicket:id="product"></div>
</wicket:container>
-igor
On Sun, Jan 25, 2009 at 12:19 PM, Prag <pr...@gmail.com> wrote:
>
> I have a page on which I want to show products. Because I want to also want
> to show products on otherpages in the same way, I've made a ProductPanel.
> I'm also using ListView to show multiple ProductPanels on each page.
>
> I'm using a panel in a list, but this gives an extra div. I don't see how I
> can remove this extra div.
>
> See my code below and the generated html output. As you can see, every
> single item in the list, gives this html: <div wicket:id="products"> and
> <div wicket:id="product">. I would like to have only 1 div instead of two.
> What is the Wicket way to solve this?
>
>
> ==== ProductsPage.html =====
> <div wicket:id="products">
> <div wicket:id="product"></div>
> </div>
>
>
> ==== ProductsPage.java =====
> public class ProductsPage extends BasePage {
> public ModelsPage() {
> List<Product> products = dao.getProducts();
>
> add(new ListView("products", products) {
> @Override
> protected void populateItem(ListItem item) {
> Product product = (Product) item.getModelObject();
> item.add(new ProductPanel("product", product));
> }
> });
> }
> }
>
> ==== ProductPanel.html =====
> <wicket:panel>
>
>
>
> </wicket:panel>
>
>
> ==== ProductPanel.java =====
> public class ProductPanel extends Panel {
> public ProductPanel(String id, Product product) {
> super(id);
>
> add(new Label("name", product.getName()));
> add(new Label("description", product.getDescription()));
> add(new Label("price", product.getPrice()));
> }
> }
>
>
> ==== Generated HTML Output =====
> <div wicket:id="products">
> <div wicket:id="product">
> <wicket:panel>
> aaaa
> aaaa
> 1111
> </wicket:panel>
> </div>
> </div>
>
> <div wicket:id="products">
> <div wicket:id="product">
> <wicket:panel>
> bbbbb
> bbbbbb
> 22222
> </wicket:panel>
> </div>
> </div>
>
> <div wicket:id="products">
> <div wicket:id="product">
> <wicket:panel>
> ccccc
> ccccc
> 33333
> </wicket:panel>
> </div>
> </div>
>
> --
> View this message in context: http://www.nabble.com/Panel-in-List%2C-remove-extra-div-tp21656188p21656188.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org