0
我目前处于这种情况,我需要使用MarkupWriter
创建复选框而不是使用.tml
。但是,这是在一个组件内,我想将复选框的值绑定到父节点的布尔值。从本质上讲,它是以下几点:通过MarkupWriter绑定组件 - 挂毯
组件
public class InnerComponent {
@Parameter
private boolean booleanValue;
void afterRender(final MarkupWriter writer) {
writer.element("input", "type", "checkbox");
writer.end();
}
}
调用页面
public class OuterPage {
@Property
private boolean checkboxValue;
@InjectComponent
private Zone booleanZone;
Object onDisplayBoolean() {
return booleanZone.getBody();
}
}
随着.tml
<html t:type="layout" title="testProject Index" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd">
<t:InnerComponent booleanValue='checkboxValue'/><br/>
<t:eventlink event='displayBoolean' zone='booleanZone'>Update</t:eventlink>
<t:zone t:id='booleanZone' id='booleanZone'>
${checkboxValue}
</t:zone>
</html>
组件的MarkupWriter
当前只写出一个简单的复选框。但它也接收布尔值作为参数。我将如何去绑定布尔参数,复选框MarkupWriter
生成?
在这个简单的例子中,选中复选框,然后通过EventLink
更新Zone
应显示父代的checkboxValue boolean
的更新值。