![](/img/trans.png)
[英]Tapestry - How to pass parameters from tml page to event handler in tapestry?
[英]Tapestry: How to set HTML checkbox from java page
我正在使用純HTML復選框(不是Tapestry類型)。 我需要將復選框設置為在Java頁面中選中。 我怎么做?
這是我的tml代碼片段
<input type="checkbox" name="leaf" id="leaf" value="leaf"/>
任何幫助,將不勝感激。 謝謝。
您需要設置選中的屬性。 我可能會使用<t:any>
組件。
TML
<t:any element="input" type="literal:checkbox" name="literal:leaf" id="prop:clientId" value="prop:currentObject.value" checked="prop:checked" />
JAVA
@Property
private SomeType currentObject;
public String getClientId() {
return "mycheckbox_" + currentObject.getId();
}
// if this returns null, tapestry won't render the attribute
public String getChecked() {
return currentObject.isSelected() ? "checked" : null;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.