0

ID Generation produces non unique IDs

asked 2008-06-20 07:49:02 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5043569

By: draymann

[moved from General, text updated]
Hi there,

I experienced problems with the generated IDs. I have a large list (data-bound) and got the message "Not unique in ID space of ..." although all explicitely given IDs were different. I managed to fix this error by explicitley giving the listitem a calculated ID (starting from listitem-0). I then changed the mold to paging. On my WINDOWS PC all was fine, but on a LINUX machine I got the same error message again (maybe not for the listitems but for something different?). The difference between the two systems let me think of a problem with threads or something like that.

The workaround was to implement my own IdGenerator that generates unique IDs in a threadsafe way. Now, all works fine. I attached my IdGenerator to the end of this post for reference. It's just a first prototype: it is quite simple and for sure it can be improved in one or another way. Though, I haven't experienced any problem with it up to now.

I am also trying to setup an example for the malfunction in the following days.
I hope I am able to reproduce the problem with artificial data too.

Do you know if there's a problem with the standard way IDs are generated? Is the generation properly synchronized?

Kind regards,

Dominik


================== IdGenerator ================== public class IdGenerator implements org.zkoss.zk.ui.sys.IdGenerator {
private Object _lockObject = new Object();
private long _id = 0;

@Override
public String nextComponentUuid(Desktop arg0, Component arg1) {
synchronized (_lockObject) {
String id = "component-" + _id;
_id++;
return id;
}

}

@Override
public String nextDesktopId(Desktop arg0) {
synchronized (_lockObject) {
String id = "desktop-" + _id;
_id++;
return id;
}
}

@Override
public String nextPageUuid(Page arg0) {
synchronized (_lockObject) {
String id = "page-" + _id;
_id++;
return id;
}
}

}


delete flag offensive retag edit

6 Replies

Sort by ยป oldest newest

answered 2008-06-24 01:52:05 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5050617

By: waterbottle

Could you provide the exception stack track log for those 2 cases?
And provide a simple reproducible code is better for us to find out the problem.

link publish delete flag offensive edit

answered 2008-06-24 08:34:40 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5051131

By: draymann

Maybe the following helps, it's the stack trace from the LINUX environment (I don't know whether it is the one with or without paging):

Jun 18, 2008 6:32:26 PM org.zkoss.zk.ui.impl.UiEngineImpl handleError:863
SEVERE: >>org.zkoss.zk.ui.UiException: Not unique in the ID space of <ChangeRequestsListComponent z_61_qi>
>> at
>>org.zkoss.zk.ui.AbstractComponent.checkIdSpaces(AbstractComponent.java
>>:301
)
>> at org.zkoss.zk.ui.AbstractComponent.setId(AbstractComponent.java:591)
>> at
>>org.zkoss.zkplus.databind.BindingListitemRenderer.setupCloneIds(Bindin
>>gLis
titemRenderer.java:136)
>> at
>>org.zkoss.zkplus.databind.BindingListitemRenderer.setupCloneIds(Bindin
>>gLis
titemRenderer.java:148)

I try to reproduce the problem as soon as I have time.
Thanks.

link publish delete flag offensive edit

answered 2008-06-24 09:10:47 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5051180

By: draymann

Probably the same bug, that is now fixed in 3.0.6:
http://sourceforge.net/tracker/index.php?func=detail&aid=1962153&group_id=152762
&atid=785191

link publish delete flag offensive edit

answered 2008-06-24 10:32:48 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5051303

By: waterbottle

Maybe you could test it on 3.0.6, it was released today.

link publish delete flag offensive edit

answered 2009-03-23 20:18:36 +0800

InfoSec812 gravatar image InfoSec812
96

I think that I am having a similar problem as well. I have written an implementation of IdGenerator which seems to work fine. The problem arises when I want to clone() a component which has children. When I do that and then attach the cloned component, I get an error because some of the children of the clone have duplicate IDs. For example, I have several places where I have a Listbox which may or may not have items attached. I always create an "invisible" Listitem with all of the appropriate children. When I need to add another Listitem, I clone() the invisible item and then append it to the Listbox. Can anyone suggest a better method, a fix, or a workaround?

Thanks,

Deven

link publish delete flag offensive edit

answered 2009-03-24 12:49:42 +0800

InfoSec812 gravatar image InfoSec812
96

I have found a work-around. Instead of putting an "invisible" component in the Listbox for later cloning, I put the Listitem component into a seperate ZUL file and use Executions.createComponent() to create the new Listitem. Probably cleaner that way anyhow.

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2008-06-20 07:49:02 +0800

Seen: 361 times

Last updated: Mar 24 '09

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