我想根据条件隐藏表。我使用此代码时出错。请帮我解决此错误。
//在Wicket:
<table class="jtrac jtrac-view" width="100%" wicket:id="request">
<tr>
<td ></td>
<td ></td>
</tr>
</table>
<table class="jtrac jtrac-view" width="100%" wicket:id="response">
<tr >
<td ></td>
<td ></td>
</tr>
</table>
I wrote java code like this.
WebMarkupContainer request = new WebMarkupContainer("request");
WebMarkupContainer response= new WebMarkupContainer("response");
add(request );
add(response);
if(time == null || time.equals("")) {
response.setVisible(false);
add(response);
}else {
request.setVisible(false);
add(request);
}
答案 0 :(得分:2)
add(request());
add(response());
private WebMarkupContainer request() {
WebMarkupContainer r = new WebMarkupContainer("request") {
@Override
protected void onConfigure() {
super.onConfigure();
setVisible(StringUtils.isEmpty(time))
}
};
r.setOutputMarkupPlaceholderTag(true);
return r;
}
private WebMarkupContainer response() {
WebMarkupContainer r = new WebMarkupContainer("response") {
@Override
protected void onConfigure() {
super.onConfigure();
setVisible(StringUtils.isNotEmpty(time));
}
};
r.setOutputMarkupPlaceholderTag(true);
return r;
}
StringUtils
来自Apache Commons:http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html