CheckBoxMultipleChoiceã¨ChoiceRendererã使ç¨ãããã§ãã¯ããã¯ã¹ã®æ¯è¼
ãæ©éãããããåºæ¬ã¯ããã ããã³ã¡ã³ãã®ã½ã¼ã¹ã®ã¾ã¾ãé ç®ã®Beanãªããã¯èªåãä½ã£ã¦ãããã®ï¼Wicket1.3ä»æ§ã«ãããã¦â¦â¦ã
private List<SampleObjectModelBean> selected; public SampleChoiceRenderer() { // èªåãåå¾ãã¦ããé ç® selected = new ArrayList<SampleObjectModelBean>(); selected.add(GenerateBeanUtility.GenerateSampleObjectModelBean(2)); selected.add(GenerateBeanUtility.GenerateSampleObjectModelBean(5)); Form form = new Form("form"); add(form); // é¸æé ç®å ¨ã¦ final List<SampleObjectModelBean> all = GenerateBeanUtility.GenerateSampleObjectModelBean(); // ãã§ãã¯ããã¯ã¹ final CheckBoxMultipleChoice multiChoice = new CheckBoxMultipleChoice("list", new PropertyModel(this, "selected"), all, new ChoiceRenderer("name", "outline")); // 表示ç¨ã©ãã« final Label label = new Label("label", "æå"); form.add(multiChoice); form.add(new Button("next") { private static final long serialVersionUID = -1359417135623629179L; // é¸æãããã®ãé£çµãã¦Labelã«ã»ãã @Override public void onSubmit() { List<SampleObjectModelBean> list = (List<SampleObjectModelBean>)multiChoice.getModelObject(); String value = ""; for (SampleObjectModelBean bean : list) { value += bean.getOutline() + ", "; } label.setModelObject(value); } }); this.add(label); }
ããããªæãã«ããã¦ãããã¾ãããã¡ãã£ã¨ååã®CheckGroupã¨Checkã®ã´ãªæ¼ãããé·ãè¦ãããã©ããã§ãã¯ä»¥å¤ã®ã³ã³ãã¼ãã³ããå ¥ã£ã¦ããããã§ãèã¯ã
// ãã§ãã¯ããã¯ã¹ final CheckBoxMultipleChoice multiChoice = new CheckBoxMultipleChoice("list", new PropertyModel(this, "selected"), all, new ChoiceRenderer("name", "outline"));
ãããã ãããã¨ã
selected.add(GenerateBeanUtility.GenerateSampleObjectModelBean(2)); selected.add(GenerateBeanUtility.GenerateSampleObjectModelBean(5));
ãããã§ãã¿ããã¨ãªããã¦ã¼ã¶ãåå¾ãã¦ãããã®ã«addãã¦ãã¾ããããã¦ã
final List<SampleObjectModelBean> all = GenerateBeanUtility.GenerateSampleObjectModelBean();
ããã£ã¡ã§é ç®å ¨ã¦ãåå¾ãã¦ãã¾ããã§ãhtmlã¯ããã
<h1>ChoiceRendererã使ç¨ãããã§ãã¯ããã¯ã¹</h1> <p>by id:hayasshãã</p> <form wicket:id="form"> <input type="submit" wicket:id="next" /> <table cellspacing="0" cellpadding="2" border="1"> <tr> <th>ãªãã¨ãä¸è¦§</th> </tr> <tr> <td><span wicket:id="list" /></td> </tr> </table> </form> <p wicket:id="label" />
ãããã¨ãä½ã¨ãã§ãã¯ãï¼ãâhttp://samplewicket.kkataka.staxapps.net/?wicket:bookmarkablePage=:sampleWicket.view.choiceRenderer.SampleChoiceRenderer
ãã½ã¼ã¹ã³ã¼ããæ¸ãããããäºãããã§ããã¨ãããã¼ãã