我想使用现有的复杂组件添加静态html。像
这样的东西<div class="form-item" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
<label for="form-item-label">Opis</label>
<t:textfield class="data" t:id="clientId" t:value="value" />
</div>
我想将textfield的id设置为参数化值clientId,而不是固定的“clientId”值。
组件的Java部分是:
public class FormItemTextField {
@Parameter(required = true, name = "value", defaultPrefix = BindingConstants.PROP)
private String value;
@Parameter(required = true, name = "clientid", defaultPrefix = BindingConstants.LITERAL)
private String clientId;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getClientId() {
return clientId;
}
}
有人可以帮忙吗?
答案 0 :(得分:0)
只需在HTML中添加DOM ID,并将其设置为您喜欢的任何内容。
<div class="form-item" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
<label for="form-item-label">Opis</label>
<t:textfield class="data" t:id="clientId" id="${myCoolId}" t:value="value" />
</div>
使用你的java:
public class FormItemTextField {
@Parameter(required = true, name = "value", defaultPrefix = BindingConstants.PROP)
private String value;
@Parameter(required = true, name = "clientid", defaultPrefix = BindingConstants.LITERAL)
private String clientId;
...
public String getMyCoolId() {
return "anythingYouWant";
}
}