Del*_*ani 17
根据这个页面:
http://2ality.blogspot.com/2009/01/uuids-for-gwt.html
这个UUID生成器与GWT一起使用:
http://www.pst.ifi.lmu.de/%7Erauschma/download/UUID.java
您可以通过重用Javascript UUID 实现并使用 JSNI 包装它来在 GWT 中生成 UUID :
public native static String uuid() /*-{
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r
: (r & 0x3 | 0x8);
return v.toString(16);
});
}-*/;
Run Code Online (Sandbox Code Playgroud)
如果您只想在 GWT 元素中使用唯一 ID(而不是 UUID),请使用:
String id = DOM.createUniqueId();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10275 次 |
| 最近记录: |