2015-04-22 130 views
0

the one listed here in the articleZK:使用自定義ID生成硒而有我使用的是自定義的ID生成的動態ID

它工作正常,但我有我爲我的標籤動態ID:

<tabpanels children="@load(vm.myTabsList) @template('myTemplate')" > 
    <template name="myTemplate" var="each"> 
     <tabpanel id="tabPanel${each.key}"> 
      <include src="zul/myTabZul.zul/> 
     </tabpanel> 
    </template> 
</tabpanels> 

我得到這個異常:

org.zkoss.zk.ui.UiException: Illegal character, }, not allowed in uuid, 

拋出錯誤不會留下多少空間actualy ...不知道我怎麼能繞過的方法。

public static void checkUuid(String uuid) { 
    int j; 
    if (uuid == null || (j = uuid.length()) == 0) 
     throw new UiException("uuid cannot be null or empty"); 

    while (--j >= 0) { 
     final char cc = uuid.charAt(j); 
     if ((cc < 'a' || cc > 'z') && (cc < 'A' || cc > 'Z') 
     && (cc < '0' || cc > '9') && cc != '_') 
      throw new UiException("Illegal character, "+cc+", not allowed in uuid, "+uuid); 
    } 
} 

雖然原始發生器似乎做得很好,但它可能不會同時生成Id。

如果有人有硒和ZK的消費,感謝您的意見。

回答

0

我認爲這是因爲你嘗試使用動態ID,但它並不需要它。

tabPanel${each.key}包含「}」講的(和標記他們從右到左檢查,所以這是第一個我們遇到)

隨着越來越多的祖爾一點我可以告訴您如何能更改。

+0

是的,這是因爲動態ID,否則它工作正常。 但我後來使用這些,所以我需要保持這種方式。 在我原來的問題中增加了一些代碼。 – TheBakker

1

我不認爲它與硒有關。

由於'tabPanel $ {each.key}'不是有效的EL表達式,最終的'}'被認爲是你的id字符串的一部分。關於如何編寫有效的EL表達式,請看here。 我建議你使用核心的cat方法連接兩個部分(tabPanel和$ {each.key})。您的代碼將變爲:

<!-- at the beginning of your file --> 
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?> 
... 
<tabpanel id="${c:cat('tabPanel',each.key)}"> 

「each.key」將正確解釋由於周圍$(它不必直接接觸){}。

我希望這不是太晚,它仍然有幫助。