[Seasar-user:10934] Re: dynamic validator
Yasuo Higa
[E-MAIL ADDRESS DELETED]
2007年 10月 10日 (水) 14:45:14 JST
Hi, all.
>
> <input type="text" id="number" />
>
> <input type="submit" value="ウミユJ" class="button" id="doApprovalConfirm" /
>
>
> public Validator getDateValidator() {
> ValidatorChain chain = new ValidatorChain();
> TRequiredValidator validator = new TRequiredValidator();
> if (number != 0) { chain.add(validator); }
> return chain;
> }
>
> I can't get the input value of number . Why?
You should get the input value via request parameter,
because Teeda sets property value after validation phase.
Please define param property in your page class as follows:
private Map params;
public Map getParams() {
return params;
}
public void setParam(Map param) {
this.param = param;
}
So, you can check the input value as follows:
public Validator getDateValidator() {
ValidatorChain chain = new ValidatorChain();
TRequiredValidator validator = new TRequiredValidator();
if (param.get("form:date") != null) {
chain.add(validator);
}
return chain;
}
"form" means id element of form tag.
--
Yasuo Higa
[E-MAIL ADDRESS DELETED]
Seasar-user メーリングリストの案内