WEB开发网
开发学院软件开发Java Tapestry 和 Wicket 的比较 阅读

Tapestry 和 Wicket 的比较

 2010-03-30 00:00:00 来源:WEB开发网   
核心提示: 清单 10. Tapestry Java 类publicabstractListgetReceivedItems();publicabstractvoidsetReceivedItems(Listitems);publicabstractActionItemgetCurrentItem();清单

清单 10. Tapestry Java 类

  public abstract List getReceivedItems(); 
  public abstract void setReceivedItems(List items); 
  public abstract ActionItem getCurrentItem(); 

清单 11. Tapestry HTML 标记

  <tr jwcid="receivedItems"> 
    <td><span jwcid="itemId">ID</span></td> 
    <td><span jwcid="subject">Subject</span></td> 
    <td><span jwcid="creator">Creator</span></td> 
    <td><span jwcid="recipient">Recipient</span></td> 
  </tr> 

在 Wicket 中,我们采用 ListView 类并匿名地实现其 populateItem() 方法,如清单 12、13 所示:

清单 12. Wicket Java 类

  add(new ListView("receivedItems", items) { 
    protected void populateItem(final ListItem item) { 
      ActionItem todo = (ActionItem) item.getModelObject(); 
 
      item.add(new Label("itemId", String.valueOf(todo.getItemId())); 
      item.add(new Label("subject", todo.getSubject())); 
      item.add(new Label("creator", todo.getCreator())); 
      item.add(new Label("recipient", todo.getRecipient())); 
    } 
  }); 

清单 13. Wicket HTML 标记

  <tr wicket:id="receivedItems"> 
    <td><span wicket:id="itemId">ID</span></a></td> 
    <td><span wicket:id="subject">Subject</span></td> 
    <td><span wicket:id="creator">Creator</span></td> 
    <td><span wicket:id="recipient">Recipient</span></td> 
  </tr> 

上一页  1 2 3 4 5 6 7 8 9 10  下一页

Tags:Tapestry Wicket 比较

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接