我想创建wicket页面,其中显示的表与数据库中的数据有关,在这个表下,有创建另一个对象到数据库的窗体。当我保存对象时,页面不刷新,所以在表格中我看不到新的一行。 如果我理解正确,要解决此问题,我必须使用ajax。我找到了指南(https://cwiki.apache.org/confluence/display/WICKET/How+to+repaint+a+ListView+via+Ajax)并在我的项目中创建了类似的东西,但它不起作用,我无法找到它不起作用的原因。我发现另一个人有问题,他们试图实现只有行/面板,但它不是我的情况。我甚至没有任何异常,只是它什么都不做。你能给我一个建议吗?Ajax没有在窗口中实现listview
java文件
public class ListPanel extends Panel {
private static final long serialVersionUID = 6953172817971228490L;
@SpringBean
RezervaceDao rezervaceDao;
public ListPanel(String id) {
super(id);
List<Rezervace> rezervace = rezervaceDao.getAllRezervace();
ListView listview = new ListView("rezervaceList", rezervace) {
private static final long serialVersionUID = 3659733406689720345L;
protected void populateItem(ListItem item) {
Rezervace r = (Rezervace) item.getModelObject();
item.add(new Label("casRezervace", r.getCasRezervace()));
item.add(new Label("jmeno", r.getJmeno()));
item.add(new Label("adresa", r.getAdresa()));
item.add(new Label("telefon", r.getTelefon()));
}
};
listview.setReuseItems(true);
// encapsulate the ListView in a WebMarkupContainer in order for it to
// update
WebMarkupContainer listContainer = new WebMarkupContainer("obal");
// generate a markup-id so the contents can be updated through an AJAX
// call
listContainer.setOutputMarkupId(true);
listContainer
.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(3)));
// add the list view to the container
listContainer.add(listview);
// finally add the container to the page
add(listContainer);
}
}
.html文件
<wicket:panel>
<div wicket:id="obal">
<table>
<tr>
<th>Čas návštěvy</th>
<th>Jméno a Příjmení</th>
<th>Adresa</th>
<th>Kontaktní telefon</th>
</tr>
<tr wicket:id="rezervaceList">
<td><span wicket:id="casRezervace"></span></td>
<td><span wicket:id="jmeno"></span></td>
<td><span wicket:id="adresa"></span></td>
<td><span wicket:id="telefon"></span></td>
</tr>
</table>
</div>
</wicket:panel>
是的,这将起作用。小记:我会打电话给列表是'固定'(因为“静态”可能会导致与'静态'混淆) – RobAu 2014-12-19 07:59:10
非常感谢,现在它完美的工作! – Eleer 2014-12-19 11:51:13