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");

你可能感兴趣的:(wicket)