所以我确实在检票口中有我的按钮,我想根据两个条件之一将他设置为两个图像之一。在一种情况下,该按钮也应该被禁用。
private static final Image rwImage = new Image("rewindButton", new ContextRelativeResource("/images/rw.png"));
private static final Image rwImageGrey = new Image("rewindButton", new ContextRelativeResource("/images/rw_grey.png"));
AjaxFallbackLink rewindButton = new AjaxFallbackLink("rw") {
@Override
public void onClick(AjaxRequestTarget target) {
// Sets page parameter to 0, and sets response page with a given page parameter.
setResponsePage(MessageStorePage.class, new PageParameters().add("currentPageParameter", 0));
//After calling above, currentPage=0;
}
};
// rewindButton.setOutputMarkupId(true);
// rewindButton.setOutputMarkupPlaceholderTag(true);
// Displays grayed out and disabled button if current page is the first one.
if (currentPage <= 0) {
rewindButton.add(rwImageGrey);
rewindButton.setEnabled(false);
} else
// Displays button if current page is not the first one.
rewindButton.add(rwImage);
// Adds "first page" button
add(rewindButton);
一切都很酷, setEnabled 工作正常,但按钮图像随机显示(错误,不像我想要的那样)。在以隐身模式启动它时它工作正常,所以缓存/cookies可能有问题,不知道:/
有任何想法吗?