我的检票口应用程序有点问题。
问题出在一个名为 OverviewPage 的页面上,这里有一些像 ListPanel 这样的面板,我的 RepeatingView 就在其中。
这个RepeatingView(列表)有一些项目,每个项目都有一个按钮,如果我按下按钮,我将被重定向到另一个页面(RegistrationPage),并且对RepeatingView(列表)进行了一些更改。
如果我现在使用RepeatingView(列表)导航回OverviewPage,列表与以前完全相同。我对列表项进行了更改,但它们不可见。(我没有按浏览器后退按钮,我点击了我的导航链接)
我知道检票页面的实例在会话中持续存在。我可以告诉 wicket 重新渲染此页面/列表吗?有哪些可能性?任何人都可以吗?
谢谢
编辑:
以下是包含 RepeatingView 的面板:
/**
*
* Constructor...
*
* @param id
*/
public ServiceListPanel(String id) {
super(id);
RepeatingView repeating = new RepeatingView("repeating");
add(repeating);
int index = 0;
// add all services to the list
for (Service service : databaseService.getAllServices()) {
AbstractItem item = new AbstractItem(repeating.newChildId());
repeating.add(item);
item.add(new ActionPanel("actions", new Model<Service>(service)));
item.add(new Label("name", service.getName()));
item.add(new Label("description", service.getDescription()));
item.add(new Label("country", service.getCountry()));
final int idx = index;
item.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return (idx % 2 == 1) ? "even" : "odd";
}
}));
index++;
}
}
下一个是应该发生更改的 ActionPanel:
/**
*
* Constructor...
*
* @param id
* @param model
*/
public ActionPanel(String id, final IModel<Service> model) {
super(id);
Link<?> link;
ContextImage image;
final ServiceUserDetails user = getSession().getUser();
final Service service = model.getObject();
// Check for groups and customize the link to subscribe or unsubscribe
if (checkUserGroups(user, service)) {
image = new ContextImage("img", "template/img/unsubscribe.gif");
link = new Link<Void>("select") {
/** */
private static final long serialVersionUID = -2153508505463870485L;
/**
*
* @see org.apache.wicket.markup.html.link.Link#onClick()
*/
@Override
public void onClick() {
ServiceRequest req = new ServiceRequest(service, user, "DELETE");
serviceProcessor.handleServiceRequest(req);
setResponsePage(new RegistrationPage());
}
};
} else { // user is not in group
image = new ContextImage("img", "template/img/subscribe.gif");
link = new Link<Void>("select") {
/** */
private static final long serialVersionUID = -2153508505463870485L;
/**
*
* @see org.apache.wicket.markup.html.link.Link#onClick()
*/
@Override
public void onClick() {
ServiceRequest req = new ServiceRequest(service, user, "PUT");
serviceProcessor.handleServiceRequest(req);
setResponsePage(new RegistrationPage());
}
};
}
link.add(image);
add(link);
}
如您所见,我唯一要更改的是一个图像,一个链接图像。用于订阅或取消订阅服务。列表项保持不变。
我对检票口很陌生,也许这就是我的问题。
希望它现在得到更好的解释。