wicket基本控件使用笔记

转自:http://shazhifeng.iteye.com/blog/300304
Label new Label(“message”,”message content”);

MutLineLabel new MutlineLabel(“message”,”我的名字:\n我的性别:”); 这里可以将\n转成<br/>,相当于Servlet里面的out.print

Link

Link link = new

Link("link") {

public void onClick() {

super.setResponsePage(NewPage.class);

}

};

注意这里的setResponsePage的参数,最常用的是两个,一个是Class类型,直接跳转到那个页面,如果需要传递参数,只要调用那个页面的构造方法就可以了,例如:setResponsePage(new NewPage(“paramValue”));

ExternalLink 一般这个控件用于外连接

<a wicket:id=”externalLink”>外连接,转向百度</a>



ExternalLink externalLink = new ExternalLink(“externalLink”,http://www.baidu.com);

BookmarkablePageLink 可以传递参数的Link

<a wicket:id=”bookmarkablePageLink”>传递参数到其它页面</a>



PageParameters parameters = new PageParameters();

parameters.put(“name”,”value”);

BookmarkablePageLink link = new BookmarkablePageLink(“bookmarkablePageLink”,NewPage.class,parameters);

PopupSettings 在客户端生成JavaScript代码实现popup窗口

<a wicket:id=”popupLink”>点击弹出窗口</a>

//创建PopupSettings

PopupSettings popup = new PopupSettings(0;

popupSettings.setHeight(400);

popupSettings.setWidth(400);

//创建使用popup的Link

Link link = new

Link("link") {

public void onClick() {

super.setResponsePage(NewPage.class);

}

};

//调用setPopupSettings方法添加进PopupSettings

link.setPopupSettings(popup);

SubmitLink 用于提交表单,调用Form的onSubmit方法

Form form = new Form("wicketForm"){

@Override

public void onSubmit(){

}

}; //创建提交链接

//创建内部提交链接,form要add这个内部提交链接

SubmitLink inSubmitLink = new SubmitLink("inSubmitLink");

form.add(inSubmitLink);

//创建外部提交链接,这个链接要add这个form

SubmitLink outSubmitLink = new SubmitLink("outSubmitLink",form);

Button

//创建按钮

Button button1 = new Button("button1"){

@Override

public void onSubmit(){

}

};

//注意这个方法,false时不调用form的onSubmit方法,true时先调用buttion1的onSubmit方法,再调用form的obSubmit方法

//一般都需要设置为false,可以实现多个按钮提交的功能

button1.setDefaultFormProcessing(false);

TextField TextField name = new TextField("name");

PasswordTextField PasswordTextField password = new PasswordTextField("password");

TextArea TextArea info = new TextArea("info");

CheckBox CheckBox bool = new CheckBox("bool");

CheckBoxMultipleChoice

List sitesList = new ArrayList();

sitesList.add("百度");

sitesList.add("新浪");

sitesList.add("搜狐");

CheckBoxMultipleChoice sites = new CheckBoxMultipleChoice("sites",sitesList);

DropDownChoice

DropDownChoice dropDownChoice = new DropDownChoice("dropdown",sitesList);

dropDownChoice.setRequired(true);

form.add(dropDownChoice);

RadioChoice RadioChoice radioChoice = new RadioChoice("radioChoice",sitesList);

Image Image image = new Image("img","images/emot1.gif");
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值