You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by ganea iulia <su...@gmail.com> on 2016/10/14 07:16:45 UTC
Repeat every 2 rows in a table
Hello,
I have in the html file, a table where I need to repeat every two rows.
So, my table is backed by a bean, where the bean values fill 2 rows of the
table.
When new bean instance is created, I need to add new 2 rows to the table.
Thank you
Re: Repeat every 2 rows in a table
Posted by ganea iulia <su...@gmail.com>.
Thank you, works great.
On Fri, Oct 14, 2016 at 12:06 PM, Peter Henderson <
peter.henderson@starjar.com> wrote:
> Hi
>
> Change your markup to
>
> ...
> <table>
> ..
> <wicket:container wicket:id="forEachItem">
> <tr>
> <td wicket:id="itemName"></td>
> <td wicket:id="itemCode"></td>
> </tr>
> <tr>
> <td wicket:id="itemId"></td>
> </tr>
> </wicket:container>
>
>
>
>
>
>
>
>
> On 14 October 2016 at 09:44, ganea iulia <su...@gmail.com> wrote:
>
> > Hello Per, thank you for the links.
> >
> > I have following html code:
> >
> > <body>
> > <form wicket:id="testForm">
> > <table class="contenidoform" cellpadding=1 cellspacing=0 border="0"
> > width="100%">
> > <thead>
> > <tr>
> > <th>Name</th>
> > <th>Code</th>
> > </tr>
> > <tr>
> > <th>Id</th>
> > </tr>
> > </thead>
> > <tbody >
> > <tr wicket:id="forEachItem">
> > <td wicket:id="itemName"></td>
> > <td wicket:id="itemCode"></td>
> > </tr>
> > <tr>
> > <td wicket:id="itemId"></td>
> > </tr>
> > </tbody>
> > </table>
> > </form>
> > </body>
> >
> > The Java code looks like this:
> >
> > public TestPage(IModel<TestBean> model) {
> > super(model);
> >
> > TestForm tst = new TestForm("testForm", model);
> > tst.setOutputMarkupId(true);
> > add(tst);
> >
> > }
> >
> > class TestForm extends Form<TestBean> {
> > /**
> > *
> > */
> > private static final long serialVersionUID = 1L;
> >
> > public TestForm(String id, IModel<TestBean> model) {
> > super(id, model);
> >
> > List<TestBean> beans = Arrays.asList(new TestBean("Name1", "Code1", 1),
> > new TestBean("Name2", "Code2", 2));
> > add(new ListView<TestBean>("forEachItem", beans) {
> > /**
> > *
> > */
> > private static final long serialVersionUID = 1L;
> >
> > @Override
> > protected void populateItem(ListItem<TestBean> item) {
> > item.add(new Label("itemName", new PropertyModel(item.getModel(),
> > "name")));
> > item.add(new Label("itemCode", new PropertyModel(item.getModel(),
> > "code")));
> > item.add(new Label("itemId", new PropertyModel(item.getModel(),
> "id")));
> > }
> > });
> > }
> >
> > @Override
> > protected void onSubmit() {
> >
> > logger.info("OnSubmit");
> >
> > }
> > }
> >
> > The code crashes here because itemId belongs to another row.
> > Could you please advise?
> >
> > Thank you
> >
> >
> >
> > On Fri, Oct 14, 2016 at 10:29 AM, Per Newgro <pe...@gmx.ch> wrote:
> >
> > > Hello ganea,
> > >
> > > you can find many information about your problem at
> > > http://examples7x.wicket.apache.org/index.html
> > > espacially
> > > http://examples7x.wicket.apache.org/repeater
> > >
> > > The user guide can you find here
> > > https://ci.apache.org/projects/wicket/guide/7.x/
> > > Repeaters are explained here
> > > https://ci.apache.org/projects/wicket/guide/7.x/guide/repeaters.html
> > >
> > > You can add a markup container to a list view item and add the required
> > > row components to it.
> > >
> > > Hope that helps
> > > Per
> > >
> > >
> > > Am 14.10.2016 um 09:16 schrieb ganea iulia:
> > >
> > >> Hello,
> > >>
> > >> I have in the html file, a table where I need to repeat every two
> rows.
> > >> So, my table is backed by a bean, where the bean values fill 2 rows of
> > the
> > >> table.
> > >> When new bean instance is created, I need to add new 2 rows to the
> > table.
> > >>
> > >> Thank you
> > >>
> > >>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
>
>
>
> --
> Peter Henderson
>
> Director
> Starjar Ltd.
> www.starjar.com
> 0330 088 1662
>
Re: Repeat every 2 rows in a table
Posted by Peter Henderson <pe...@starjar.com>.
Hi
Change your markup to
...
<table>
..
<wicket:container wicket:id="forEachItem">
<tr>
<td wicket:id="itemName"></td>
<td wicket:id="itemCode"></td>
</tr>
<tr>
<td wicket:id="itemId"></td>
</tr>
</wicket:container>
On 14 October 2016 at 09:44, ganea iulia <su...@gmail.com> wrote:
> Hello Per, thank you for the links.
>
> I have following html code:
>
> <body>
> <form wicket:id="testForm">
> <table class="contenidoform" cellpadding=1 cellspacing=0 border="0"
> width="100%">
> <thead>
> <tr>
> <th>Name</th>
> <th>Code</th>
> </tr>
> <tr>
> <th>Id</th>
> </tr>
> </thead>
> <tbody >
> <tr wicket:id="forEachItem">
> <td wicket:id="itemName"></td>
> <td wicket:id="itemCode"></td>
> </tr>
> <tr>
> <td wicket:id="itemId"></td>
> </tr>
> </tbody>
> </table>
> </form>
> </body>
>
> The Java code looks like this:
>
> public TestPage(IModel<TestBean> model) {
> super(model);
>
> TestForm tst = new TestForm("testForm", model);
> tst.setOutputMarkupId(true);
> add(tst);
>
> }
>
> class TestForm extends Form<TestBean> {
> /**
> *
> */
> private static final long serialVersionUID = 1L;
>
> public TestForm(String id, IModel<TestBean> model) {
> super(id, model);
>
> List<TestBean> beans = Arrays.asList(new TestBean("Name1", "Code1", 1),
> new TestBean("Name2", "Code2", 2));
> add(new ListView<TestBean>("forEachItem", beans) {
> /**
> *
> */
> private static final long serialVersionUID = 1L;
>
> @Override
> protected void populateItem(ListItem<TestBean> item) {
> item.add(new Label("itemName", new PropertyModel(item.getModel(),
> "name")));
> item.add(new Label("itemCode", new PropertyModel(item.getModel(),
> "code")));
> item.add(new Label("itemId", new PropertyModel(item.getModel(), "id")));
> }
> });
> }
>
> @Override
> protected void onSubmit() {
>
> logger.info("OnSubmit");
>
> }
> }
>
> The code crashes here because itemId belongs to another row.
> Could you please advise?
>
> Thank you
>
>
>
> On Fri, Oct 14, 2016 at 10:29 AM, Per Newgro <pe...@gmx.ch> wrote:
>
> > Hello ganea,
> >
> > you can find many information about your problem at
> > http://examples7x.wicket.apache.org/index.html
> > espacially
> > http://examples7x.wicket.apache.org/repeater
> >
> > The user guide can you find here
> > https://ci.apache.org/projects/wicket/guide/7.x/
> > Repeaters are explained here
> > https://ci.apache.org/projects/wicket/guide/7.x/guide/repeaters.html
> >
> > You can add a markup container to a list view item and add the required
> > row components to it.
> >
> > Hope that helps
> > Per
> >
> >
> > Am 14.10.2016 um 09:16 schrieb ganea iulia:
> >
> >> Hello,
> >>
> >> I have in the html file, a table where I need to repeat every two rows.
> >> So, my table is backed by a bean, where the bean values fill 2 rows of
> the
> >> table.
> >> When new bean instance is created, I need to add new 2 rows to the
> table.
> >>
> >> Thank you
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
--
Peter Henderson
Director
Starjar Ltd.
www.starjar.com
0330 088 1662
Re: Repeat every 2 rows in a table
Posted by ganea iulia <su...@gmail.com>.
Hello Per, thank you for the links.
I have following html code:
<body>
<form wicket:id="testForm">
<table class="contenidoform" cellpadding=1 cellspacing=0 border="0"
width="100%">
<thead>
<tr>
<th>Name</th>
<th>Code</th>
</tr>
<tr>
<th>Id</th>
</tr>
</thead>
<tbody >
<tr wicket:id="forEachItem">
<td wicket:id="itemName"></td>
<td wicket:id="itemCode"></td>
</tr>
<tr>
<td wicket:id="itemId"></td>
</tr>
</tbody>
</table>
</form>
</body>
The Java code looks like this:
public TestPage(IModel<TestBean> model) {
super(model);
TestForm tst = new TestForm("testForm", model);
tst.setOutputMarkupId(true);
add(tst);
}
class TestForm extends Form<TestBean> {
/**
*
*/
private static final long serialVersionUID = 1L;
public TestForm(String id, IModel<TestBean> model) {
super(id, model);
List<TestBean> beans = Arrays.asList(new TestBean("Name1", "Code1", 1),
new TestBean("Name2", "Code2", 2));
add(new ListView<TestBean>("forEachItem", beans) {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<TestBean> item) {
item.add(new Label("itemName", new PropertyModel(item.getModel(),
"name")));
item.add(new Label("itemCode", new PropertyModel(item.getModel(),
"code")));
item.add(new Label("itemId", new PropertyModel(item.getModel(), "id")));
}
});
}
@Override
protected void onSubmit() {
logger.info("OnSubmit");
}
}
The code crashes here because itemId belongs to another row.
Could you please advise?
Thank you
On Fri, Oct 14, 2016 at 10:29 AM, Per Newgro <pe...@gmx.ch> wrote:
> Hello ganea,
>
> you can find many information about your problem at
> http://examples7x.wicket.apache.org/index.html
> espacially
> http://examples7x.wicket.apache.org/repeater
>
> The user guide can you find here
> https://ci.apache.org/projects/wicket/guide/7.x/
> Repeaters are explained here
> https://ci.apache.org/projects/wicket/guide/7.x/guide/repeaters.html
>
> You can add a markup container to a list view item and add the required
> row components to it.
>
> Hope that helps
> Per
>
>
> Am 14.10.2016 um 09:16 schrieb ganea iulia:
>
>> Hello,
>>
>> I have in the html file, a table where I need to repeat every two rows.
>> So, my table is backed by a bean, where the bean values fill 2 rows of the
>> table.
>> When new bean instance is created, I need to add new 2 rows to the table.
>>
>> Thank you
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Repeat every 2 rows in a table
Posted by Per Newgro <pe...@gmx.ch>.
Hello ganea,
you can find many information about your problem at
http://examples7x.wicket.apache.org/index.html
espacially
http://examples7x.wicket.apache.org/repeater
The user guide can you find here
https://ci.apache.org/projects/wicket/guide/7.x/
Repeaters are explained here
https://ci.apache.org/projects/wicket/guide/7.x/guide/repeaters.html
You can add a markup container to a list view item and add the required
row components to it.
Hope that helps
Per
Am 14.10.2016 um 09:16 schrieb ganea iulia:
> Hello,
>
> I have in the html file, a table where I need to repeat every two rows.
> So, my table is backed by a bean, where the bean values fill 2 rows of the
> table.
> When new bean instance is created, I need to add new 2 rows to the table.
>
> Thank you
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org