-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I implemented a custom IdGenerator (a combination of the ComponentTypeIdGenerator & the IdAsUuidGenerator from books.zkoss.org/wiki/User:Jimmyshiau/EtcIdGenerator) to create some selenium tests.
This is my code:
public String nextComponentUuid(Desktop desktop, Component comp,
ComponentInfo info) {
if (info != null) {
for (Iterator<Property> it = info.getProperties().iterator(); it.hasNext();) {
Property p = it.next();
if ("id".equals(p.getName())) {
if (!p.getRawValue().startsWith("$") && !p.getRawValue().endsWith(">")){
return p.getRawValue().replaceAll("\\s", "");
}
}
}
}
return nextComponentUuid(desktop, comp);
}
public String nextComponentUuid(Desktop desktop, Component comp) {
Component p = comp.getParent();
if (p != null && !(comp instanceof Grid) && !(comp instanceof Grid)
&& !(comp instanceof Grid) && !(comp instanceof Grid)) {
String uuidPrefox = "";
String pUuid = p.getUuid();
if (pUuid.startsWith("grid")) {
p = getCollectionComponent(Grid.class, comp);
uuidPrefox = getCollectionComponentUuidPrefix(pUuid, "row");
} else if (pUuid.startsWith("listbox")) {
p = getCollectionComponent(Listbox.class, comp);
uuidPrefox = getCollectionComponentUuidPrefix(pUuid, "listitem");
} else if (pUuid.startsWith("tree")) {
p = getCollectionComponent(Tree.class, comp);
uuidPrefox = getCollectionComponentUuidPrefix(pUuid, "treeitem");
} else if (pUuid.startsWith("combobox")) {
p = getCollectionComponent(Combobox.class, comp);
uuidPrefox = getCollectionComponentUuidPrefix(pUuid, "comboitem");
}
if (!Strings.isBlank(uuidPrefox))
return uuidPrefox + getComponentName(comp) + "_" +
formatter.format(getComponentIdIndex(p, comp));
}
return getComponentName(comp) + "_" + formatter.format(getComponentIdIndex(desktop, comp));
}
This works as it should, until an id in the zul is named 'about' or 'home'. For example:
<div id="home" />
Then I get the following error:
Problem accessing /pages/home. Reason:
It took too much time to look for unique UUID. Please check the implementation of IdGenerator.
Caused by:
org.zkoss.zk.ui.UiException: It took too much time to look for unique UUID. Please check the implementation of IdGenerator. at org.zkoss.zk.ui.AbstractComponent.nextUuid(AbstractComponent.java:493) at org.zkoss.zk.ui.AbstractComponent.setPage0(AbstractComponent.java:467) at org.zkoss.zk.ui.AbstractComponent.setPageBefore(AbstractComponent.java:393) at org.zkoss.zk.ui.impl.AbstractUiFactory.newComponent(AbstractUiFactory.java:102) at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:809) at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:778) at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:687) at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:749) at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:709) at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:651) at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:401) at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:316)
Is this normal behaviour, are these reserved keywords? Or is it a zk bug?
Thanks
Hello.
I tested the code and it worked when component ID in the zul is named 'about' or 'home' like this:
<zk>
<div id="home" />
<div id="about" />
</zk>
And I got the same error when I changed both the two ID to the same, like:
<zk>
<div id="same" />
<div id="same" />
</zk>
I guess the problem was cause by the components which having duplicated ID. Can you check are there existing components which have the same ID?
Asked: 2014-04-25 12:11:20 +0800
Seen: 24 times
Last updated: Apr 27 '14