[英]Tapestry: How to set HTML checkbox from java page
I am using plain HTML checkbox(not Tapestry type). 我正在使用纯HTML复选框(不是Tapestry类型)。 I need to set the checkbox to checked in my java page. 我需要将复选框设置为在Java页面中选中。 How do I do that? 我怎么做?
Here is my tml code fragment 这是我的tml代码片段
<input type="checkbox" name="leaf" id="leaf" value="leaf"/>
Any help would be appreciated. 任何帮助,将不胜感激。 Thanks. 谢谢。
You need to set the checked property. 您需要设置选中的属性。 I'd probably use the <t:any>
component. 我可能会使用<t:any>
组件。
TML TML
<t:any element="input" type="literal:checkbox" name="literal:leaf" id="prop:clientId" value="prop:currentObject.value" checked="prop:checked" />
JAVA 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.