Hi,
it worked fine for me, I attach my own code so you can compare. Btw, why
don't you just use a listview with a model that filters out the selected
items? Imo it's simpler and more elegant. And another remark: you can bind
your checkbox to a boolean (see my example).
Regards,
Carlos
On 8/26/07, pokkie <[EMAIL PROTECTED]> wrote:
>
>
> I have a RepeatingView that I generate, each row is represented as a
> WebMarkupContainer.
> At the end of each row I add a checkbox. When the "Delete Selected" button
> is called,
> I wish to remove the selected row from the RepeatingView and update the
> page
> to reflect
> this status.
>
> ----------------------
> WebMarkupContainer mainExerciseItem = new
> WebMarkupContainer(newChildId());
>
> add(mainExerciseItem);
>
> mainExerciseItem.add(new CheckBox("exerciseSelected", new
> PropertyModel(mainMemberProgramExerciseHolder,
> "memberProgramExerciseSelected")));
> ----------------------
>
> Currently, I iterate over the items in the RepeatingView, check if they
> are
> selected, and
> subsequently call remove(WebMarkupContainer).
>
> ----------------------
> while (exerciseTable.iterator().hasNext()) {
> WebMarkupContainer container = (WebMarkupContainer)
> exerciseTable.iterator().next();
> if
> (container.get("exerciseSelected").getModelObjectAsString().equals(
> StaticData.TRUE))
> {
> exerciseTable.remove(container);
> }
> ----------------------
>
> The problem is that it seems that after calling the remove() method, it
> seems to be entering a loop and
> never returns.
>
> I have tried to call the render() method, but haven't had any luck yet.
>
> Any help would be much appreciated
>
> -- pokkie
> --
> View this message in context:
> http://www.nabble.com/RepeatingView-%3A-Removing-a-table-row-tf4331444.html#a12335918
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
package web.repeat;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.PropertyModel;
@SuppressWarnings("serial")
public class RepeatingTest extends WebPage {
private static class Item implements Serializable {
public final int number;
public boolean selected = false;
public Item(int number) {
this.number = number;
}
}
private static class ItemContainer extends WebMarkupContainer {
public final Item item;
public ItemContainer(String id, Item item) {
super(id);
this.item = item;
add(new Label("itemNumber", new PropertyModel(item, "number")));
add(new CheckBox("itemSelected", new PropertyModel(item, "selected")));
}
}
private class ItemsForm extends Form {
private List<ItemContainer> itemContainers = new ArrayList<ItemContainer>();
public ItemsForm(String id) {
super(id);
RepeatingView itemRepeater = new RepeatingView("itemRepeater");
add(itemRepeater);
for (int i = 0 ; i < 10 ; i++) {
ItemContainer itemContainer = new ItemContainer("itemContainer" + i, new Item(i));
itemContainers.add(itemContainer);
itemRepeater.add(itemContainer);
}
}
protected void onSubmit() {
Iterator<ItemContainer> itemContainerIterator = itemContainers.iterator();
while (itemContainerIterator.hasNext()) {
ItemContainer itemContainer = itemContainerIterator.next();
if (itemContainer.item.selected) {
itemContainer.remove();
itemContainerIterator.remove();
}
}
}
}
public RepeatingTest() {
add(new ItemsForm("itemsForm"));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]