此例子为wicket中在页面中点检索后,在本页面显示出检索结果所用到的控件:
import java.util.ArrayList;
import java.util.List;
import jp.co.infomart.foods.common.admin.page.BasePage;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
/**
*
* @author admin
*/
public class Test_ListView extends BasePage {
private Form form;
private static List books = new ArrayList();
WebMarkupContainer container;
public Test_ListView(){
super();
form = new Form("myForm");
this.add(form);
container = new WebMarkupContainer("listViewContainer");
container.setOutputMarkupId(true);
//
ListView listView = new ListView("books",books){
@Override
protected void populateItem(ListItem item) {
Test_ListViewModel book = (Test_ListViewModel)item.getModelObject();
item.add(new Label("id",Integer.toString(book.getId())));
item.add(new Label("title",book.getTitle()));
item.add(new Label("author",book.getAuthor()));
}
};
container.add(listView);
form.add(container);
AjaxButton ajaxButton = new AjaxButton("ajaxButton") {
@Override
protected void onSubmit(AjaxRequestTarget art, Form<?> form) {
init();
art.addComponent(container);
}
@Override
protected void onError(AjaxRequestTarget art, Form<?> form) {
throw new UnsupportedOperationException("Not supported yet.");
}
};
form.add(ajaxButton);
}
public void init(){
books.clear();
for(int i=1;i<10;i++){
Test_ListViewModel book = new Test_ListViewModel();
book.setId(i);
book.setAuthor("author"+i);
book.setTitle("title"+i);
books.add(book);
}
}
}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>test</title>
</head>
<body bgcolor="#FFFFFF" text="#000000" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" onUnload="fCloseWin()">
<form wicket:id="myForm">
<div wicket:id="listViewContainer">
<table width="240" border="1">
<tr>
<th>序号</th>
<th>书名</th>
<th>作者</th>
</tr>
<tr wicket:id="books">
<td wicket:id="id">id</td>
<td wicket:id="title">title</td>
<td wicket:id="author">author</td>
</tr>
</table>
</div>
<input type="submit" wicket:id="ajaxButton"/>
</form>
</body>
</html>
public class Test_ListViewModel {
private int id;
private String title;
private String author;
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
分享到:
相关推荐
24.使用Wicket和Spring测试驱动开发 24.1。配置运行时环境 24.2。配置基于JUnit的集成测试环境 24.3。摘要 25. Wicket最佳实践 25.1。正确封装组件 25.2。将模型和页面数据放在字段中 25.3。正确命名Wicket ID 25.4...
wicket的ajax范例(级联选择框)
Ajax-jaulp-wicket.zip,这个项目是ApacheWicket组件和实用程序的集合。,ajax代表异步javascript和xml。它是多种web技术的集合,包括html、css、json、xml和javascript。它用于创建动态网页,其中网页的小部分在不...
wicket例子和开发指南,指南为PDF文档,例子为wicket自带例子。
从wicket官网中下载的wicket1.4.7中jar包,对于编写wicket相关的程序有所需要的朋友可以下载
wicket 开发指南 比较全面的介绍wicket的使用
Wicket has been around since 2004 and it has been an Apache project since 2007. During these years it has proved to be a solid and valuable solution for building enterprise web applications. Wicket ...
wicket开发指南,wicket 新型的web开发框架,现以能无逢支持jsr168/286
Wicket开发指南 Wicket开发指南 Wicket开发指南
wicket文档和源码
Wicket,有一个优秀的Web框架。和Struts和Webwork类似的Java WEB开发框架。...基于规则的配置(有效减少了XML配置文件的使用,与Spring相比,Spring项目组也已意识到了这一点,并在新版中对此进行了改进)。学习曲线低
wicket-js 使在组件和行为中编写和处理自定义 JavaScript 和变得容易。 它有助于将 Wicket Ajax Behavior 侦听器与实际客户端 UI 功能分开,同时保持与 Wicket 组件的耦合。 它提供了一个(基本的),允许您在 ...
Wicket 入门,以及Eclipse里建立project
今年,由于几个同事和朋友说起培训和使用Wicket 时缺少资料,所以 决定将这份文档完成,算是给自己一个交待吧,也当作为开源软件作一些自己的贡献。通 过近六周的笔耕,这份《Wicket 开发指南》终于写完了。这是第一...
wicket 基础知识培训,主要是讲解wicket入门知识,通过和struts比较来进行讲解。
wicket1,4.17中除了jar包和example外的部分,分为3部分上传的原因是本人的上传容量限制为20M,该部分包括api帮助文档和源码等
Wicket是什么?简单点说,它是一个基于Java 的Web开发框架,与Struts,WebWork, Tapestry相类似。其特点在于对Html 和代码进行了有效的分离(有利于程序员和美工的合 作),基于规则的配置 ( 减少了 XML 等配置文件...
wicket国际化例子 含有wicket:message StringResourceModel 等读取properties资源文件的代码示例
这是继wicket的简单实例之后,关于tree的简单用法,初学者可以下载下来学习如何生成树,以及树的使用
wicket 6.x api.chm wicket帮助文档