我最近已從Wicket 1.5.11升級到Wicket 6.13 升級後,我面臨的問題與鏈接的onclick行爲。Wicket 6.13鏈接onclick行爲不工作與ajax onclick行選擇
我們有一個可點擊的行,其中包含少量列(其中之一是指向新頁面的鏈接)。 現在,如果我們點擊鏈接,然後我們被帶到新頁面,我們點擊行(除了鏈接)該行被選中(使用Ajax調用)。
這是工作的罰款與檢票1.5.11,我跟檢票6.13面臨的問題
Link類:
public class MyLink extends Link {
private static final long serialVersionUID = 5808539933400105591L;
private MyRow myRow;
public MyLink(String id, MyRow myRow) {
super(id);
this.myRow = myRow;
}
/** {@inheritDoc} */
@Override
public void onClick() {
//sets the response page where this needs to be redirected.
this.setResponsePage(new ResponseReadPage(this.myRow));
}
}
填充方法:
@Override
protected void populateItem(final ListItem item) {
final MyRow myRow = (MyRow) item.getModelObject();
item.add(new Label("naam", myRow.getName()));
item.add(new Label("id", myRow.getCode()));
MyLink myLink = new MyLink("myLink", myRow);
item.add(myLink);
final MyRow selectedRow = this.session.getSelectedRow();
if (selectedRow != null
&& selectedRow.equals(myRow)) {
this.session.selectedRow(myRow);
item.add(new AttributeModifier("class", "activeRow"));
this.selecteditem = item;
//some business logic
}
item.add(new AjaxEventBehavior("onclick") {
/** {@inheritDoc} */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected void onEvent(final AjaxRequestTarget target) {
final WebMarkupContainer container = (WebMarkupContainer) MyListView.this.getParent()
.getParent().get("myContainer");
MyListView.this.session.setSelectedRow(myRow);
if (MyListView.this.currentActiveItem != null) {
MyListView.this.previousActiveItem = MyListView.this.currentActiveItem;
MyListView.this.previousActiveItem.add(new AttributeModifier("class", ""));
}
item.add(new AttributeModifier("class", "activeRow"));
MyListView.this.currentActiveItem = item;
if (MyListView.this.previousActiveItem != null) {
target.add(MyListView.this.previousActiveItem);
}
if (MyListView.this.selecteditem != null
&& !MyView.this.selecteditem.equals(item)) {
MyListView.this.selecteditem.add(new AttributeModifier("class", ""));
target.add(MyListView.this.selecteditem);
}
target.add(item);
target.add(container);
}
});
}
當我嘗試點擊在鏈接的LINK而不是onClick方法上,行的AjaxBehavior的onclick事件被調用。 任何人都可以指出我正確的方向來得到這個排序嗎?
更新:當我右鍵單擊該鏈接並在另一個選項卡中打開鏈接的onClick方法的調用發生成功按預期。
爲什麼6.13而不是最新的6.18? –
@ martin-g客戶要求:/ –