下面实现一个简单的表单提交,input 信息在message标签中显示的功能:
html代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form wicket:id="form">
<input type='text' wicket:id="input"/><br/>
<input type="submit" wicket:id="submit" value="提交"/>
</form>
<!--表单提交后用于显示text内容-->
<lable wicket:id="message"></lable>
</body>
</html>
java代码:
package com.wicket;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.Model;
public class FormPage extends WebPage {
public FormPage() {
final Label message=new Label("message","");
add(message);
Form form=new Form("form");
add(form);
/*注意这里一定要加个model,不然会报:
java.lang.IllegalStateException: Attempt to set model object on null model of component: form:input
异常
*/
final TextField<String> input=new TextField("input",new Model(""));
form.add(input);
form.add(new Button("submit"){
@Override
public void onSubmit() {
super.onSubmit();
//获取input 数据
String value = input.getModelObject();
//message 标签显示数据
message.setDefaultModelObject(value);
//input 标签清空
input.setDefaultModelObject("");
}
});
}
}
相关推荐
最新的web事件开发框架
1 Chapter 1: Validating and Converting User Input 7 Introduction 7 Performing form-level custom validation 7 Creating a custom validator 12 Composing multiple validators into a single reusable ...
wicket开发指南,wicket 新型的web开发框架,现以能无逢支持jsr168/286
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:message StringResourceModel 等读取properties资源文件的代码示例
测试Wicket表单 23.3。使用TagTester测试标记 23.4。摘要 24.使用Wicket和Spring测试驱动开发 24.1。配置运行时环境 24.2。配置基于JUnit的集成测试环境 24.3。摘要 25. Wicket最佳实践 25.1。正确封装组件 25.2。将...
wicket 开发指南 比较全面的介绍wicket的使用
wicket 基础知识培训,主要是讲解wicket入门知识,通过和struts比较来进行讲解。
wicket学习文档
wicket 6.x api.chm wicket帮助文档
Wicket 入门,以及Eclipse里建立project
wicket编译所需的maven库,搬运
wicket-menu.zip,Wicket菜单
wicket-examples 示例 wicket-examples 示例 wicket-examples 示例 wicket-examples 示例
从wicket官网中下载的wicket1.4.7中jar包,对于编写wicket相关的程序有所需要的朋友可以下载
wicket例子和开发指南,指南为PDF文档,例子为wicket自带例子。
wicket相关书籍 好东西啊
Wicket,有一个优秀的Web框架。和Struts和Webwork类似的Java WEB开发框架。优点在于对HTML和业务代码进行了有效的分离(流行的WEB框架大多如此)。基于规则的配置(有效减少了XML配置文件的使用,与Spring相比,...