1

Custom id generator zk 6.5.3 gives error on some id keywords

asked 2014-04-25 12:11:20 +0800

zkh gravatar image zkh
22 2

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

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-04-27 04:51:01 +0800

RaymondChao gravatar image RaymondChao
386 1 4
ZK Team

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?

link publish delete flag offensive edit

Comments

That was indeed the problem RaymondChao, thanks.

zkh ( 2014-04-28 12:31:29 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-04-25 12:11:20 +0800

Seen: 24 times

Last updated: Apr 27 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More