1

我想根据条件隐藏表格。使用此代码时出错。请帮助我解决此错误。

//IN 检票口:

<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);
}
4

1 回答 1

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

于 2013-11-08T06:52:21.890 回答