[Seasar-user:7712] Re: [Teeda] Validatorでチェックする桁数を可変にしたい

松崎 学 [E-MAIL ADDRESS DELETED]
2007年 5月 19日 (土) 22:24:44 JST


大谷さん

松崎です、お世話になります。
返信ありがとうございます。試してみます!

On Fri, 18 May 2007 17:11:00 +0900
"Shinpei Ohtani" <[E-MAIL ADDRESS DELETED]> wrote:

> 大谷です。
> 
> あまりキレイでは無いですが、
> 下記のようにすればできます。
> 
> 肝なところは、TeedaExtensionでは
> 定数またはTigerアノテーションで記述したValidatorは
> 内部的にEL式(#{コンポーネント名.プロパティ名})の形で
> saveされています。
> 
> そのため、initialize()で直接Validatorを管理しているところに
> addするようにしておいて、その前に動くLogicをかませば
> 動的にValidatorのプロパティを決定することが出来ます。
> 
> 
> package examples.teeda.web.add;
> 
> import javax.faces.internal.ValidatorResource;
> 
> import org.seasar.framework.convention.NamingConvention;
> import org.seasar.teeda.extension.validator.TRequiredValidator;
> 
> public class AddPage {
> 
> 	// public static final String arg1_TGreaterThanConstantValidator = null;
> 
> 	// public static final String arg2_TGreaterThanConstantValidator = null;
> 
> 	private int arg1;
> 
> 	private int arg2;
> 
> 	private int result;
> 
> 	private NamingConvention namingConvention;
> 
> 	public String initialize() {
> 		String componentName = namingConvention
> 				.fromClassNameToComponentName(this.getClass().getName());
> 		ValidatorResource.addValidator("#{" + componentName + ".arg1}",
> 				new TRequiredValidator());
> 		ValidatorResource.addValidator("#{" + componentName + ".arg2}",
> 				new TRequiredValidator());
> 		return null;
> 	}
> 
> 	public int getArg1() {
> 		return arg1;
> 	}
> 
> 	public void setArg1(int arg1) {
> 		this.arg1 = arg1;
> 	}
> 
> 	public int getArg2() {
> 		return arg2;
> 	}
> 
> 	public void setArg2(int arg2) {
> 		this.arg2 = arg2;
> 	}
> 
> 	public int getResult() {
> 		return result;
> 	}
> 
> 	public void setResult(int result) {
> 		this.result = result;
> 	}
> 
> 	public String doCalculate() {
> 		result = arg1 + arg2;
> 		return null;
> 	}
> 
> 	public NamingConvention getNamingConvention() {
> 		return namingConvention;
> 	}
> 
> 	public void setNamingConvention(NamingConvention namingConvention) {
> 		this.namingConvention = namingConvention;
> 	}
> 
> }
> 
> 宜しくお願いします。
> 
> 
> 07/05/17 に 松崎 学<[E-MAIL ADDRESS DELETED]> さんは書きました:
> > 松崎です。いつもお世話になっております。
> >
> > TByteLengthValidatorやTNumberLengthValidatorでチェックする桁数を
> > ロジックでセットする事は可能でしょうか?
> > 入力可能桁数をDBのテーブル定義情報から取得してチェックしたいのです。
> >
> > アノテーションでソースにリテラル指定する事しか出来ないのでしょうか?
> >
> > 以上、よろしくお願い致します。
> >
> >
> > _______________________________________________
> > Seasar-user mailing list
> > [E-MAIL ADDRESS DELETED]
> > https://ml.seasar.org/mailman/listinfo/seasar-user
> >
> 
> 
> -- 
> =============================
> Shinpei Ohtani
> [E-MAIL ADDRESS DELETED]
> =============================
> _______________________________________________
> Seasar-user mailing list
> [E-MAIL ADDRESS DELETED]
> https://ml.seasar.org/mailman/listinfo/seasar-user






Seasar-user メーリングリストの案内