ZK窗口在ID空间中不唯一 [英] ZK window not unique in ID space
问题描述
在我们的项目中,我们使用 ZK
作为网页。有一个组合框
,它有列表。当选择时,它通过 onSelect
从java对象获取数据,我已经给出了逻辑。
当我选择一个有4 listboxes
在该页面上填充数据根据选择。当我选择第一次,没有问题发生。
但第二次,我得到一个错误弹出窗口,如窗口的id空间中的不唯一,并显示列表框项目id必须填写
注意:虽然它显示这个错误,我得到了 listboxes
根据组合框选择正确填写。仍然我不能阻止这个错误发生..
您的问题是一个冲突的ZK的 id空格
。
一点背景。
ZK为组件在运行时,如果你在浏览器中打开DOM,你会看到每个组件都有一些机器可读的id。
但是,你也可以给组件一个id。此ID不转到DOM,但允许您在应用程序中引用组件。
这两个不应该混淆。你遇到的冲突是后一种类型的id;您在Java代码中或在ZUL文件中为组件分配了一个id,在运行时它不是唯一的。
您描述的只是第二个时间你点击是一个告示牌在这里。您在活动中添加的内容中定义了ID,您在完成操作后不会删除此内容。
请考虑以下示例:
@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);
}
这将在您第一次单击时工作myButton
,但会在第二次点击时抛出您的错误。这是因为第二个事件试图添加 myLabel
到 myWindow
,但已经有一个 myLabel
有很多方法可以解决这个问题,取决于你想要做什么。
有一个请查看有关 ID空间的ZK文档,了解更多信息。
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..
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.
这篇关于ZK窗口在ID空间中不唯一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!