型チェックについて

WicketTypeCheck.png

必須チェック

TextField#setRequired(true);

TypeCheckExamPage?.html

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:wicket="http://wicket.apache.org/">
<head>
<title>Wicket Type Check Examination Page</title>
</head>
<body>
<strong>Wicket Type Check Examination Page</strong>
<p align="right"><a wicket:id="back">back to menu</a></p>
<span wicket:id="msg"> error message will be here </span>
<form wicket:id="f">
	<fieldset>
		<legend>Input Type Check</legend>
		<table border="0">
			<tr>
				<td>boolCol</td><td>:</td>
				<td><input type="text" wicket:id="boolCol" size="20" /></td>
				<td>(true / false)</td>
			</tr>
			<tr>
				<td>byteCol</td><td>:</td>
				<td><input type="text" wicket:id="byteCol" size="20" /></td>
				<td>(<span wicket:id="byteColMax"/>〜<span wicket:id="byteColMin"/>)</td>
			</tr>
			<tr>
				<td>charCol</td><td>:</td>
				<td><input type="text" wicket:id="charCol" size="20" /></td>
				<td>(<span wicket:id="charColMax"/>〜<span wicket:id="charColMin"/>)</td>
			</tr>
			<tr>
				<td>shortCol</td><td>:</td>
				<td><input type="text" wicket:id="shortCol" size="20" /></td>
				<td>(<span wicket:id="shortColMax"/>〜<span wicket:id="shortColMin"/>)</td>
			</tr>
			<tr>
				<td>intCol</td><td>:</td>
				<td><input type="text" wicket:id="intCol" size="20" /></td>
				<td>(<span wicket:id="intColMax"/>〜<span wicket:id="intColMin"/>)</td>
			</tr>
			<tr>
				<td>longCol</td><td>:</td>
				<td><input type="text" wicket:id="longCol" size="20" /></td>
				<td>(<span wicket:id="longColMax"/>〜<span wicket:id="longColMin"/>)</td>
			</tr>
			<tr>
				<td>floatCol</td><td>:</td>
				<td><input type="text" wicket:id="floatCol" size="20" /></td>
				<td>(<span wicket:id="floatColMax"/>〜<span wicket:id="floatColMin"/>)</td>
			</tr>
			<tr>
				<td>doubleCol</td><td>:</td>
				<td><input type="text" wicket:id="doubleCol" size="20" /></td>
				<td>(<span wicket:id="doubleColMax"/>〜<span wicket:id="doubleColMin"/>)</td>
			</tr>
		</table>
	</fieldset>
	<input type="submit" value="POST" />
</form>
</body>
</html>

TypeCheckExamVo?.java

package com.snail.wicket.exam.validation;

import java.io.Serializable;

public class TypeCheckExamVo implements Serializable{
  private static final long serialVersionUID = 8118905069882346381L;
  
  public static final String BOOL_COL = "boolCol";
  public static final String BYTE_COL = "byteCol";
  public static final String CHAR_COL = "charCol";
  public static final String SHORT_COL = "shortCol";
  public static final String INT_COL = "intCol";
  public static final String LONG_COL = "longCol";
  public static final String FLOAT_COL = "floatCol";
  public static final String DOUBLE_COL = "doubleCol";
  public static final String DATE_COL = "dateCol";
  public static final String TIME_COL = "timeCol";
  
  private boolean boolCol;
  private byte byteCol;
  private char charCol;
  private short shortCol;
  private int intCol;
  private long longCol;
  private float floatCol;
  private double doubleCol;
  
  public boolean isBoolCol() {
    return boolCol;
  }
  public void setBoolCol(boolean boolCol) {
    this.boolCol = boolCol;
  }
  public byte isByteCol() {
    return byteCol;
  }
  public void setByteCol(byte byteCol) {
    this.byteCol = byteCol;
  }
  public char getCharCol() {
    return charCol;
  }
  public void setCharCol(char charCol) {
    this.charCol = charCol;
  }
  public short getShortCol() {
    return shortCol;
  }
  public void setShortCol(short shortCol) {
    this.shortCol = shortCol;
  }
  public int getIntCol() {
    return intCol;
  }
  public void setIntCol(int intCol) {
    this.intCol = intCol;
  }
  public long getLongCol() {
    return longCol;
  }
  public void setLongCol(long longCol) {
    this.longCol = longCol;
  }
  public float getFloatCol() {
    return floatCol;
  }
  public void setFloatCol(float floatCol) {
    this.floatCol = floatCol;
  }
  public double getDoubleCol() {
    return doubleCol;
  }
  public void setDoubleCol(double doubleCol) {
    this.doubleCol = doubleCol;
  }
}

TypeCheckExamPage?.java

package com.snail.wicket.exam.validation;

import org.apache.wicket.extensions.markup.html.form.DateTextField;
import org.apache.wicket.extensions.yui.calendar.DatePicker;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.validation.validator.DateValidator;
import org.apache.wicket.validation.validator.NumberValidator;
import org.apache.wicket.validation.validator.StringValidator;

import com.snail.wicket.exam.MenuPage;

public class RangeCheckExamPage extends WebPage {
  private static final long serialVersionUID = 3914250268292061821L;

  private FeedbackPanel feedback = new FeedbackPanel("msg");

  private RangeCheckExamVo vo = new RangeCheckExamVo();

  private Form form = new Form("f", new CompoundPropertyModel(vo));

  private Link backLink = new Link("back") {
    private static final long serialVersionUID = 6481057398828649660L;

      @Override
      public void onClick() {
        setResponsePage(new MenuPage());
      }
    };

  private TextField int1TextField = new TextField(RangeCheckExamVo.INT1);
  private TextField int2TextField = new TextField(RangeCheckExamVo.INT2);
  private TextField int3TextField = new TextField(RangeCheckExamVo.INT3);
  private TextField int4TextField = new TextField(RangeCheckExamVo.INT4);
  private TextField int5TextField = new TextField(RangeCheckExamVo.INT5);
  private TextField str1TextField = new TextField(RangeCheckExamVo.STR1);
  private TextField str2TextField = new TextField(RangeCheckExamVo.STR2);
  private TextField str3TextField = new TextField(RangeCheckExamVo.STR3);
  private TextField str4TextField = new TextField(RangeCheckExamVo.STR4);

  private DateTextField date1TextField = new DateTextField(RangeCheckExamVo.DATE1,"yyyy年MM月dd日");
  private DateTextField date2TextField = new DateTextField(RangeCheckExamVo.DATE2,"yyyy年MM月dd日");
  private DateTextField date3TextField = new DateTextField(RangeCheckExamVo.DATE3,"yyyy年MM月dd日");

  public RangeCheckExamPage() {
    add(form);
    add(feedback);
    add(backLink);

    int1TextField.setRequired(true);
    int1TextField.add(new NumberValidator.MinimumValidator(
        RangeCheckExamVo.INT1_MIN));
    form.add(int1TextField);
    form.add(new Label(RangeCheckExamVo.INT1 + "Min",
        Integer.toString(RangeCheckExamVo.INT1_MIN)));

    int2TextField.setRequired(true);
    int2TextField.add(new NumberValidator.MaximumValidator(
        RangeCheckExamVo.INT2_MAX));
    form.add(int2TextField);
    form.add(new Label(RangeCheckExamVo.INT2 + "Max",
        Integer.toString(RangeCheckExamVo.INT2_MAX)));

    int3TextField.setRequired(true);
    int3TextField.add(new NumberValidator.RangeValidator(
        RangeCheckExamVo.INT3_MIN, RangeCheckExamVo.INT3_MAX));
    form.add(int3TextField);
    form.add(new Label(RangeCheckExamVo.INT3 + "Min",
        Integer.toString(RangeCheckExamVo.INT3_MIN)));
    form.add(new Label(RangeCheckExamVo.INT3 + "Max",
        Integer.toString(RangeCheckExamVo.INT3_MAX)));

    int4TextField.setRequired(true);
    int4TextField.add(NumberValidator.POSITIVE);
    form.add(int4TextField);

    int5TextField.setRequired(true);
    int5TextField.add(NumberValidator.NEGATIVE);
    form.add(int5TextField);

    str1TextField.add(new StringValidator.MinimumLengthValidator(
        RangeCheckExamVo.STR1_MIN));
    form.add(str1TextField);
    form.add(new Label(RangeCheckExamVo.STR1 + "Min",
        Integer.toString(RangeCheckExamVo.STR1_MIN)));

    str2TextField.add(new StringValidator.MaximumLengthValidator(
        RangeCheckExamVo.STR2_MAX));
    form.add(str2TextField);
    form.add(new Label(RangeCheckExamVo.STR2 + "Max",
        Integer.toString(RangeCheckExamVo.STR2_MAX)));

    str3TextField.add(new StringValidator.LengthBetweenValidator(
        RangeCheckExamVo.STR3_MIN, RangeCheckExamVo.STR3_MAX));
    form.add(str3TextField);
    form.add(new Label(RangeCheckExamVo.STR3 + "Min",
        Integer.toString(RangeCheckExamVo.STR3_MIN)));
    form.add(new Label(RangeCheckExamVo.STR3 + "Max",
        Integer.toString(RangeCheckExamVo.STR3_MAX)));
    
    str4TextField.add(new StringValidator.ExactLengthValidator(
        RangeCheckExamVo.STR4_LENGTH));
    form.add(str4TextField);
    form.add(new Label(RangeCheckExamVo.STR4 + "Exact",
        Integer.toString(RangeCheckExamVo.STR4_LENGTH)));

    date1TextField.add(DateValidator.minimum(RangeCheckExamVo.DATE1_MIN));
    date1TextField.add(new DatePicker());
    form.add(date1TextField);
    form.add(new Label(RangeCheckExamVo.DATE1 + "Min",
        RangeCheckExamVo.DATE1_MIN.toString()));
    
    date2TextField.add(DateValidator.maximum(RangeCheckExamVo.DATE2_MAX));
    date2TextField.add(new DatePicker());
    form.add(date2TextField);
    form.add(new Label(RangeCheckExamVo.DATE2 + "Max",
        RangeCheckExamVo.DATE2_MAX.toString()));

    date3TextField.add(DateValidator.range(RangeCheckExamVo.DATE3_MIN,RangeCheckExamVo.DATE3_MAX));
    date3TextField.add(new DatePicker());
    form.add(date3TextField);
    form.add(new Label(RangeCheckExamVo.DATE3 + "Min",
        RangeCheckExamVo.DATE3_MIN.toString()));
    form.add(new Label(RangeCheckExamVo.DATE3 + "Max",
        RangeCheckExamVo.DATE3_MAX.toString()));
  }
}

Java#Wicket


添付ファイル: fileWicketTypeCheck.png 2542件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS   sitemap
Last-modified: 2008-02-18 (月) 00:00:47 (6082d)
Short-URL: http://at-sushi.com/pukiwiki/index.php?cmd=s&k=1d7a58cce4
ISBN10
ISBN13
9784061426061