ZK window not unique in ID space

戏子无情 提交于 2019-12-07 10:13:44

问题


In our project we use ZK for webpages. There is a combobox which has lists. When selected, it fetches data from a java object through onSelect, i have given the logic. when i select one there are 4 listboxes on that page to be filled with data according to the selection. when i select first time, no problem occurs.

But on second time i get an error pop-up like "Not Unique in the id space of Window" and showing the list box item id which have to be filled on select.

Can any one help out there?

Note: Though it shows this error i get the listboxes filled correctly according to the combo box selection. Still i cant stop this error occurring..


回答1:


Your issue is a conflict of ids in ZK's id space.

A bit of background..

ZK generates ids for components at runtime, if you open up the DOM in the browser you'll see each component has some machine readable id.

However, you can also give components an id. This id does not go to the DOM but lets you reference the component in your application.

These two shouldn't be confused. The conflict you're experiencing is with the latter type of id; you are assigning a component an id in your Java code or in your ZUL file which, at runtime, is not unique.

The case you describe where it only happens the second time you click is a tell tale sign here. The content you are adding on the event has an id defined in it and you are not removing this content when you are done.

Consider the following example:

@Wire
private Window myWindow;

@Listen(Events.ON_CLICK + " = #myButton")
public void onMyButtonClicked() {
    Label myLabel = new Label("sean is cool");
    myLabel.setId("myLabel");
    myLabel.setParent(myWindow);
}

This will work the first time you click myButton, but will throw your error on the second click. That is because the second event tries to add myLabel to myWindow but there is already a myLabel there.

There are lots of ways to resolve this depending on what you are trying to do.
Have a look through the ZK documentation on ID Spaces for more.



来源:https://stackoverflow.com/questions/10186769/zk-window-not-unique-in-id-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!