Ajaxを介してエントリを削除した後、PropertyListViewで更新しようとしていますが、何らかの理由で機能しません。
PropertyListViewをWebMarkupContainerに追加し、リストをこのビューに追加しました。
誰かが助けることができます
import java.util.ArrayList;
import java.util.List;
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.PropertyListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
@SuppressWarnings("serial")
public class StockViewPanel extends Panel{
private WebMarkupContainer listContainer;
@SuppressWarnings("rawtypes")
private PropertyListView plw;
@SuppressWarnings({ "rawtypes", "unchecked" })
public StockViewPanel(String id) {
super(id);
IModel model = new LoadableDetachableModel() {
@Override
protected Object load() {
return WicketApplication.getStockEntrys();
}};
plw = new PropertyListView("stockEntrys", model )
{
@Override
protected void populateItem(final ListItem item)
{
//StockEntry stockEntry = (StockEntry) item.getModelObject();
item.add(new Label("name"));
//SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
item.add(new Label("date"/*, formatter.format(stockEntry.getDate())*/));
//NumberFormat nf = NumberFormat.getInstance(new Locale("da", "dk"));
item.add(new Label("number"/*, nf.format(stockEntry.getNumber())*/));
item.add(new Label("price"/*, nf.format(stockEntry.getPrice())*/));
item.add(new AjaxLink("deleteEntryLink"){
@Override
public void onClick( AjaxRequestTarget target )
{
List list = new ArrayList(WicketApplication.getStockEntrys());
Object ob = item.getModelObject();
list.remove(ob);
WicketApplication.setEntrys(list);
target.add(listContainer);
}
});
}
};
listContainer = new WebMarkupContainer("listContainer");
listContainer.setOutputMarkupId(true);
listContainer.add(plw);
add(listContainer);
}
}
<html>
<body>
<wicket:panel>
<table wicket:id="listContainer">
<thead>
<th>Navn</th>
<th>Dato</th>
<th>Antal</th>
<th>Pris</th>
<th></th>
</thead>
<tbody>
<tr wicket:id="stockEntrys" class="stockEntry">
<td wicket:id="name">name</td>
<td wicket:id="date">date</td>
<td wicket:id="number">number</td>
<td wicket:id="price">price</td>
<td> <a href="#" wicket:id="deleteEntryLink">DELETE</a> </td>
</tr>
</tbody>
</table>
</wicket:panel>
</body>
</html>