2012-05-23 55 views
2

你好, 我想知道是否有可能改變檢票輸出html代碼。例如對於組件「CheckBoxMultipleChoice」,您將獲得以下html輸出。是否可以更改導葉輸出?

<span wicket:id="letters"> 
<input name="letters" type="checkbox" value="0" id="letters_0"/><label for="letters_0">fff</label><br/> 
<input name="letters" type="checkbox" value="1" id="letters_1"/><label for="letters_1">aaa</label><br/> 
<input name="letters" type="checkbox" value="2" id="letters_2"/><label for="letters_2">bbb</label><br/> 
<input name="letters" type="checkbox" value="3" id="letters_3"/><label for="letters_3">ccc</label><br/> 
<input name="letters" type="checkbox" value="4" id="letters_4"/><label for="letters_4">ddd</label><br/> 
</span> 

如果我不希望<br/>標籤,我能做些什麼? 問候

回答

3

沒有,摘自documentation

組件可能會改變他們的參考標記,更換標籤的身體或標籤後插入標記。但組件不能從標記流中移除標籤。這是一個重要保證,因爲平面設計師可能會在影響視覺表現的組件標籤上設置屬性。

但是如果您要添加/刪除的組件之間的新生產線的空間,你可以改變成分的顯示塊/直列

@Override 
protected void onComponentTag(ComponentTag tag) { 
    super.onComponentTag(tag); 
    //block or inline 
    tag.put("style", "display:block"); 
} 

,或者使用一個CSS類

5

這取決於零件。

對於基於Panel的任何情況,您總是可以對組件(MyPanel.java)進行子類化並提供不同的標記文件(MyPanel.html)。只要你有相同的wicket:id在那裏,它工作正常。

對於在其源代碼中嵌入了標記元素的內置Wicket組件,如CheckBoxMultipleChoice,則受制於組件的自定義API。在你的情況下,它看起來像你想CheckBoxMultipleChoice#setSuffix