`
jackliao
  • 浏览: 77873 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

wicket 综合应用实例-在线匹萨店

阅读更多



 一个wicket 综合应用实例-在线匹萨店

这个例子对初学wicket很有帮助,可以帮助你很好理解wicket开发框架的基本概念,希望能使初学wicket的兄弟快速入门。

 

实现的业务流程如下图:

选择好自己喜欢的匹萨后点击提交,将信息带到下个页面显示出来


Pizza.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>Pizza</title>
	</head>
	<body>
		<form wicket:id="pizzaForm">
			<div style="font-weight: bold;" font-weight="" bold="">
				<big>在线比萨饼店</big>
			</div>
			<table style="text-align: left; width: 600px; height: 200px;"
				border="1" cellpadding="0" cellspacing="0">
				<tbody>
					<tr>
						<td style="font-weight: bold; text-align: right;">
							比萨饼面皮:
						</td>
						<td>
							<select wicket:id="crust">
								<option>
									option 1
								</option>
								<option>
									option 2
								</option>
								<option>
									option 3
								</option>
							</select>
						</td>
					</tr>
					<tr>
						<td style="font-weight: bold; text-align: right;">
							配料:
						</td>
						<td>
							意大利辣香肠
							<input wicket:id="pepperoni" type="checkbox" />
							香肠
							<input wicket:id="sausage" type="checkbox" />
							&nbsp;洋葱
							<input wicket:id="onions" type="checkbox" />
							&nbsp;绿胡椒
							<input wicket:id="greenPeppers" type="checkbox" />
						</td>
					</tr>
					<tr>
						<td style="font-weight: bold; text-align: right;">
							备注:
						</td>
						<td>
							<input maxlength="50" size="50" wicket:id="comments" type="text" />
						</td>
					</tr>
					<tr>
						<td style="text-align: center;" colspan="2">
							<input value="Submit" name="Submit" type="submit" />
						</td>
					</tr>
				</tbody>
			</table>
		</form>
	</body>
</html>

 Pizza.java
 

public class Pizza extends WebPage
{
	public Pizza()
	{
		super();
		PizzaForm pizzaForm = new PizzaForm("pizzaForm");
		add(pizzaForm);
	}

}

 

PizzaForm.java

public class PizzaForm extends Form
{
	private static final long serialVersionUID = 1L;

	private DropDownChoice crustDropDown;

	private CheckBox pepperoniCheckBox = new CheckBox("pepperoni");

	private CheckBox sausageCheckBox = new CheckBox("sausage");

	private CheckBox onionsCheckBox = new CheckBox("onions");

	private CheckBox greenPeppersCheckBox = new CheckBox("greenPeppers");

	private TextField commentsTextField = new TextField("comments");

	public PizzaForm(String id)

	{
		super(id);

		PizzaModel pizzaModel = new PizzaModel();

		setModel(new CompoundPropertyModel(pizzaModel));

		crustDropDown = new DropDownChoice(

		"crust", new PropertyModel(pizzaModel, "crust"), Arrays
				.asList(new CrustType[]

				{ new CrustType("Thin & Crispy"),

				new CrustType("Hand Tossed"),

				new CrustType("Pan Pizza") }),

		new ChoiceRenderer("text", "id"));

		add(crustDropDown);

		add(pepperoniCheckBox);

		add(sausageCheckBox);

		add(onionsCheckBox);

		add(greenPeppersCheckBox);

		add(commentsTextField);

	}

	@Override
	protected void onSubmit()
	{
		PizzaModel pizzaModel = (PizzaModel) getModelObject();
		setResponsePage(new PizzaList(pizzaModel));
	}

}

 

CrustType.java

public class CrustType implements Serializable
{

	private static final long serialVersionUID = 1L;

	private String id;

	private String text;

	public CrustType()
	{
		super();
	}

	public CrustType(String crustName)
	{
		setId(crustName);
		setText(crustName);
	}

	
	public String getId()
	{
		return id;
	}

	public void setId(String id)
	{
		this.id = id;
	}

	public String getText()
	{
		return text;
	}

	public void setText(String text)
	{
		this.text = text;
	}

	@Override
	public String toString()
	{
		return getText();
	}

}

 

PizzaModel.java

public class PizzaModel implements Serializable
{

	private static final long serialVersionUID = 1L;

	private String crust;

	private boolean pepperoni;

	private boolean sausage;

	private boolean onions;

	private boolean greenPeppers;

	private String comments;

	public String getComments()
	{
		return comments;
	}

	public void setComments(String comments)
	{
		this.comments = comments;
	}

	public String getCrust()
	{
		return crust;
	}

	public void setCrust(String crust)
	{
		this.crust = crust;
	}

	public boolean getGreenPeppers()
	{
		return greenPeppers;
	}

	public void setGreenPeppers(boolean greenPeppers)
	{
		this.greenPeppers = greenPeppers;
	}

	public boolean getOnions()
	{
		return onions;
	}

	public void setOnions(boolean onions)
	{
		this.onions = onions;
	}

	public boolean getPepperoni()
	{
		return pepperoni;
	}

	public void setPepperoni(boolean pepperoni)
	{
		this.pepperoni = pepperoni;
	}

	public boolean getSausage()
	{
		return sausage;
	}

	public void setSausage(boolean sausage)

	{
		this.sausage = sausage;
	}

}

 

PizzaList.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>PizzaList.html</title>

		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="this is my page">
		<meta http-equiv="content-type" content="text/html; charset=gbk">

		<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

	</head>

	<body>
		<table style="text-align: left; width: 600px; height: 200px;"
			border="1" cellpadding="0" cellspacing="0">
			<tbody>
				<tr>
					<td style="font-weight: bold; text-align: right;">
						比萨饼面皮:
					</td>
					<td>
						<span wicket:id="crust">Hello</span>
					</td>
				</tr>
				<tr>
					<td style="font-weight: bold; text-align: right;">
						配料:
					</td>
					<td>
						意大利辣香肠:&nbsp;
						<span wicket:id="pepperoni"></span> 香肠:&nbsp;
						<span wicket:id="sausage"></span>&nbsp;洋葱: &nbsp;
						<span wicket:id="onions"></span>&nbsp;绿胡椒:&nbsp;
						<span wicket:id="greenPeppers"></span>
					</td>
				</tr>
				<tr>
					<td style="font-weight: bold; text-align: right;">
						备注:
					</td>
					<td>
						<span wicket:id="comments"></span>
					</td>
				</tr>
			</tbody>
		</table>


	</body>
</html>

 

PizzaList.java

public class PizzaList extends WebPage
{

	/**
	 * 
	 */
	public PizzaList()
	{
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param model
	 */
	public PizzaList(IModel<?> model)
	{
		super(model);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param pageMap
	 */
	public PizzaList(IPageMap pageMap)
	{
		super(pageMap);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param parameters
	 */
	public PizzaList(PageParameters parameters)
	{
		super(parameters);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param pageMap
	 * @param model
	 */
	public PizzaList(IPageMap pageMap, IModel<?> model)
	{
		super(pageMap, model);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param pageMap
	 * @param parameters
	 */
	public PizzaList(IPageMap pageMap, PageParameters parameters)
	{
		super(pageMap, parameters);
		// TODO Auto-generated constructor stub
	}

	public PizzaList(PizzaModel pizzaModel)

	{

		super();

		add(new Label("crust", pizzaModel.getCrust()));

		add(new Label("pepperoni", new Boolean(pizzaModel.getPepperoni())

		.toString()));

		add(new Label("sausage", new Boolean(pizzaModel.getSausage())
				.toString()));

		add(new Label("onions", new Boolean(pizzaModel.getOnions()).toString()));

		add(new Label("greenPeppers", new Boolean(pizzaModel.getGreenPeppers())

		.toString()));

		add(new Label("comments", pizzaModel.getComments()));

	}

}

 

页面的跳转、Model的运用、页面元素的构造都运用到了,是个很不错的wicket教程,希望大家喜欢!

  • 大小: 6.2 KB
  • 大小: 5 KB
分享到:
评论
1 楼 linkerlin 2010-08-16  
有没有链接?
就这么多了?

相关推荐

    de.flapdoodle.wicket--incubator-6.14.0.zip

    Scala是一种多范式的编程语言,结合了面向对象和函数式编程的概念,广泛应用于大数据处理、Web应用开发以及复杂的系统架构。然而,与任何其他编程语言一样,确保Scala代码的全面测试和覆盖率至关重要。这就是...

    wicket-in-action-0.9-source

    它提供了丰富的实例,涵盖了Wicket的核心特性和最佳实践,对于希望提升Web开发技能的Java程序员来说,是一份不可多得的学习资料。通过深入研究这些源代码,你可以更好地领略Wicket的优雅和强大,从而在构建高效、可...

    wicket-bean-validation-0.6.zip

    【标题】: "Wicket-Bean-Validation-0.6.zip" 这个压缩包"**Wicket-Bean-Validation-0.6.zip**"是针对Apache Wicket框架的一个扩展,名为Wicket-Bean-Validation,主要用于在Java环境中实现模型对象的验证。Wicket-...

    wicket-menu-6.5.0.zip

    总结起来,"wicket-menu-6.5.0.zip"是一个展示Wicket框架构建菜单系统的实例,它涵盖了菜单组件的创建、数据绑定、动态更新以及用户交互等方面的知识,对于想要深入了解Wicket或者提高Web应用开发能力的开发者来说,...

    wicket-core-1.5-RC4.2.zip

    Wicket是一款开源的Java Web应用程序框架,它强调组件化开发,提供了一种模型-视图-控制器(MVC)架构。Wicket的核心库包含了构建Web应用所需的基本组件、事件处理和生命周期管理功能。这个版本可能是对1.5主版本的...

    wicket简单实例

    **Wicket简单实例详解** Wicket是一款开源的Java Web应用程序框架,它强调组件化和模型-视图-控制器(MVC)的设计模式。这个“wicket简单实例”是为了帮助初学者理解Wicket的工作原理和基本操作,通过运行这些示例...

    wicket-in-action-0.9-binary

    Wicket是一个用Java编写的开源Web应用程序框架,它以其组件化、轻量级和强大的模型-视图-控制器(MVC)架构而闻名。本资源包中的内容可能包括示例应用程序、库文件和其他辅助工具,旨在帮助开发者更好地理解和使用...

    pax-wicket-samples-view-franchisee-0.7.12.zip

    Pax Wicket提供了一种将Wicket应用与OSGi服务集成的方法,使得在模块化系统中构建Web应用变得更加容易。版本号0.7.12表明这是该项目的一个特定发行版,通常包括修复的bug、新增的功能以及性能优化。 【描述】"ark....

    wicket-kendo-ui-6.8.0.zip

    Wicket是一个基于Java的服务器端Web应用程序框架,它以其组件模型和强健的可测试性而受到开发者的欢迎。Kendo UI则是一个JavaScript库,提供了丰富的用户界面组件,包括数据网格、图表、日期选择器等,用于创建交互...

    Wicket开发指南-简体版

    Wicket是一个开源的Java Web应用框架,它借鉴了ASP.NET的设计理念,但又具有自己的特色。该框架的目标是提高开发效率并简化Web应用程序的构建过程。 **1.2 关于“重新发明轮子”的讨论** 尽管Wicket与其他Java Web...

    wicket-util-7.0.0-M2.zip

    droitatedDB.zip,datarobot for android是一个轻量级的框架,如果您不想直接处理android s sqlite数据库,那么就不必直接处理它,如果需要的话,让我们直接访问它。

    danhaywood-isis-wicket-excel-1.4.0.zip

    总的来说,Apache Isis的wicket-excel扩展组件是面向数据密集型应用的一个实用工具,它通过与Wicket框架的紧密集成,使得开发者能够快速创建支持Excel导出的业务应用,提高了开发效率和用户体验。开源项目的性质也...

    wicket-kendo-ui-6.13.1.zip

    Wicket是Java编程语言中的一个轻量级、组件化的Web应用程序框架,而Kendo UI则是一个强大的前端开发工具集,提供了丰富的用户界面组件,如数据网格、日历、图表等,用于创建交互性强、视觉效果良好的网页应用。...

    fortuity-wicket-1.0.5-sources.jar

    fortuity-wicket-1.0.5-sources.jar

    fortuity-wicket-1.0.4-sources.jar

    fortuity-wicket-1.0.4-sources.jar

    fortuity-wicket-1.0.7-sources.jar

    fortuity-wicket-1.0.7-sources.jar

    fortuity-wicket-1.0.6-sources.jar

    fortuity-wicket-1.0.6-sources.jar

    fortuity-wicket-1.0.3-sources.jar

    fortuity-wicket-1.0.3-sources.jar

    wicket-examples

    wicket-examples 示例 wicket-examples 示例 wicket-examples 示例 wicket-examples 示例

    wicket-jquery-ui

    wicket-jquery-ui Wicket 1.5.x 和 Wicket 6.x 中的 jQuery UI 集成 文物 jQuery UI wicket-jquery-ui 日历wicket-jquery-ui-calendar 插件wicket-jquery-ui-plugins 剑道 UI wicket-kendo-ui 入门 为了开始使用...

Global site tag (gtag.js) - Google Analytics