自定义校验对象如何进行客户端验证

最近在研究tapestry,对其它的客户端验证产生疑惑,代码如下:
html:
<html>
<head>
</head>
<body jwcid="@Body">
<table width="400" border="1">
    <form jwcid="loginForm">
        <tr>
            <td colspan="2" width="100%" align="center">
                <span jwcid="@Insert" value="ognl:errorMsg"/>
            </td>
        </tr>
        <tr>
            <td colspan="2" width="100%" align="center">LOGIN</td>
        </tr>
        <tr>
            <td width="32%" align="right">Username:</td>
            <td align="left"><input type="text" jwcid="username" size="20"/></td>
        </tr>
        <tr>
            <td width="32%" align="right">Password:</td>
            <td align="left"><input type="password" jwcid="password" size="20"/></td>
        </tr>
        <tr>
            <td align="center"><input type="submit" value="Login"/></td>
            <td> <input jwcid="startDate@DatePicker" value="ognl:startDate" displayName="Start Date"/></td>
        </tr>
        <tr>
            <td colspan="2" align="center"><a href="#" jwcid="registe">Registe</a></td>
            <td colspan="2" align="center"><a href="#" jwcid="showAjax">ShowAjax</a></td>
        </tr>
    </form>
</table>
</body>
</html>

page:
<page-specification class="com.suzsoft.framework.example.web.pages.Home">
    <property name="password"/>
    <property name="errorMsg"/>
    <property name="startDate"/>
    <bean name="passwordValidator" class="com.suzsoft.framework.common.PasswordValidator"></bean>
    <bean name="delegate" class="org.apache.tapestry.valid.ValidationDelegate"></bean>
    <component id="loginForm" type="Form">
        <binding name="listener" value="listener:loginSubmit"/>
        <binding name="clientValidationEnabled" value="true" />
        <binding name="delegate" value="beans.delegate"></binding>
    </component>
    <component id="username" type="TextField" >
        <binding name="value" value="username" />
        <binding name="validators" value="validators:required"/>
    </component>
    <component id="password" type="TextField">
        <binding name="value" value="password"></binding>
        <binding name="validators" value="beans.passwordValidator"/>
        <binding name="hidden" value="true"/>
    </component>
    <component id="registe" type="PageLink">
        <binding name="page" value="literal:Registe"></binding>
    </component>
    <component id="showAjax" type="PageLink">
        <binding name="page" value="literal:ShowAjax"></binding>
    </component>
</page-specification>

自定义校验对象java文件:
public class PasswordValidator implements Validator {
    public void validate(IFormComponent field, ValidationMessages message, Object object) throws ValidatorException {
        String password = (String) object;
        if (!"123456".equals(password)) {
            throw new ValidatorException("The password is invalid!");
        }

    }

    public boolean getAcceptsNull() {
        return true;  //To change body of implemented methods use File | Settings | File Templates.
    }

    public boolean isRequired() {
        return true;  //To change body of implemented methods use File | Settings | File Templates.
    }

    public void renderContribution(IMarkupWriter writer, IRequestCycle cycle, FormComponentContributorContext context, IFormComponent field) {
        writer.attribute("style","background-color:#999999");
    }
}



为何我clientValidationEnabled==true,只有username产生客户端验证,而password却没有在客户端产生javascript,进行客户端校验呢?请.

你可能感兴趣的:(JavaScript,java,html,tapestry)