在Java中实现静态ID生成器 [英] Implementing static ID generator in java

查看:329
本文介绍了在Java中实现静态ID生成器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 https://github.com/zkoss/zk/blob/master/zk/src/org/zkoss/zk/ui/impl/StaticIdGenerator.java

Mu问题是,我该如何尝试?在具有静态ID生成器并在zk.xml中添加配置之后,下一步是什么?我将如何运行它并获取生成的ID?

Mu question is, how do I try it? After having a static id generator and adding the configurations in the zk.xml, what's next? How will I be able to run it and get the generated ids?

非常感谢您.

推荐答案

您无需运行"它.如果在配置(zk.xml)中指定了自定义ID生成器,则运行的zk应用程序将使用它为客户端上的每个小部件自动创建一个新ID.使用静态ID生成器仅需确保始终按相同的顺序创建ID,默认的ID有点随机.

You do not need to "run it". If you specify a custom ID generator in the configuration (zk.xml), the zk application you run will use it to automatically create a new ID for every widget on the client. Using a static ID generator just makes sure that the IDs are always created in the same sequence, the default one is somewhat random.

您可以在浏览器中看到ID(在开发者控制台中,html树将为您显示某些元素的"id"属性).您也可以通过Component.getUuid()访问它们.

You can see the IDs in the browser (in the developer console, the html tree will show you the "id" attributes of certain elements). You can also access them by Component.getUuid().

顺便说一句,还有一个内置的静态ID生成器实现:org.zkoss.zk.ui.impl.StaticIdGenerator.阅读 zk的测试提示,他们在此提及并还要说明为什么要使用它.

By the way, there is also a built-in implementation of a static ID generator: org.zkoss.zk.ui.impl.StaticIdGenerator. Read zk's testing tipps, they mention it there and also explain why you would use it.

这篇关于在Java中实现静态ID生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆