こんな画面

WicketRegexp.png

RegularExpressionExamPage?.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 Regular Expression Check Examination Page</title>
</head>
<body>
<strong>Wicket Regular Expression 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>Regular Expression Check</legend>
    <table border="0">
      <tr>
        <td>e-mail</td><td>:</td>
        <td><input type="text" wicket:id="eMail" size="20" /></td>
        <td></td>
      </tr>
      <tr>
        <td>zip code</td><td>:</td>
        <td><input type="text" wicket:id="zipCode" size="20" /></td>
        <td></td>
      </tr>
      <tr>
        <td>telephone</td><td>:</td>
        <td><input type="text" wicket:id="telNumber" size="20" /></td>
        <td></td>
      </tr>
    </table>
  </fieldset>
  <input type="submit" value="POST" />
</form>
</body>
</html>

RegularExpressionExamVo?.java

package com.snail.wicket.exam.validation;

import java.io.Serializable;

public class RegularExpressionExamVo implements Serializable {
  private static final long serialVersionUID = 4594914073339024288L;
  private String zipCode;
  private String eMail;
  private String telNumber;
  public static final String ZIP_CODE="zipCode";
  public static final String E_MAIL="eMail";
  public static final String TEL_NUMBER="telNumber";

  public String getZipCode() {
    return zipCode;
  }
  public void setZipCode(String zipCode) {
    this.zipCode = zipCode;
  }
  public String getEMail() {
    return eMail;
  }
  public void setEMail(String mail) {
    eMail = mail;
  }
  public String getTelNumber() {
    return telNumber;
  }
  public void setTelNumber(String telNumber) {
    this.telNumber = telNumber;
  }

}

RegularExpressionExamPage?.java

package com.snail.wicket.exam.validation;

import org.apache.wicket.markup.html.WebPage;
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.PatternValidator;

import com.snail.wicket.exam.MenuPage;


public class RegularExpressionExamPage extends WebPage {
  private static final long serialVersionUID = 652236807507547113L;

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

  private RegularExpressionExamVo vo = new RegularExpressionExamVo();

  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 eMailTextField = new TextField(RegularExpressionExamVo.E_MAIL);
  private TextField telNumberTextField = new TextField(RegularExpressionExamVo.TEL_NUMBER);
  private TextField zipCodeTextField = new TextField(RegularExpressionExamVo.ZIP_CODE);

  public RegularExpressionExamPage() {
    add(form);
    add(feedback);
    add(backLink);
    
    eMailTextField.add(new PatternValidator("[a-zA-Z0-9.]+@[a-zA-Z0-9.]+"));
    form.add(eMailTextField);
    
    telNumberTextField.add(new PatternValidator("([0-9]+-)+[0-9]+"));
    form.add(telNumberTextField);
    
    zipCodeTextField.add(new PatternValidator("[0-9]{3}-[0-9]{4}"));
    form.add(zipCodeTextField);
  }
}

Java#Wicket


添付ファイル: fileWicketRegexp.png 2071件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS   sitemap
Last-modified: 2008-02-20 (水) 02:58:51 (5909d)
Short-URL: https://at-sushi.com:443/pukiwiki/index.php?cmd=s&k=2c7b4fd73c
ISBN10
ISBN13
9784061426061