簡體   English   中英

交叉形式驗證問題掛毯

[英]Cross-form validation issue tapestry

我是Java的新手....我使用工具Tapestry框架在java中進行一些研究...當我調用@Component“Form”時,我有一些異常問題... ... tapestry拋出異常:

嵌入式組件loginForm在組件類com.fit.pages.Login(或Login的超類)中定義,但在組件模板中不存在(classpath:com / fit / pages / Login.tml)。

context eventType

啟用

org.apache.tapestry5.ioc.internal.OperationException

嵌入式組件loginForm在組件類com.fit.pages.Login(或Login的超類)中定義,但在組件模板中不存在(classpath:com / fit / pages / Login.tml)。

跟蹤

    **Triggering event 'activate' on Index
    Constructing instance of page class com.fit.pages.Login
    Creating ComponentAssembler for com.fit.pages.Login**

我的代碼看起來像這樣

公共課登錄{

private String userName;

@Property
private String password;

@Inject
@Property
private Users users;

@SessionState
private User user;

@Component(id="loginForm")
private Form loginForm;

@Inject
private Messages messages;

public String getUserName() {
    return userName;
}



public void setUserName(String userName) {
    this.userName = userName;
}


void onValidate(){
    User authenticatedUser = Security.authenticate(userName, password, users);
    if(authenticatedUser != null){
        user = authenticatedUser;
    }else{
        loginForm.recordError(messages.get("authentication-failed"));
    }
}



@OnEvent
Object onSubmit(){
    System.out.println("form was submited");
    Class nextPage = null;
    User authenticatedUser = Security.authenticate(userName, password, users);
    if(authenticatedUser != null){
        user = authenticatedUser;
        nextPage = Index.class;
    } else {

    nextPage = Registration.class;
    }
    return nextPage;
}

和login.tml中的代碼:

請登錄:

    <t:form id="loginForm">
    <table>
            <tr>
                <td>
                <t:label t:for="userName"/>:
                </td>
                <td>
                    <input type="text" t:type="textfield"  t:id="userName" 
                    t:value="userName" t:validate="required"/>
                </td>
            </tr>
            <tr> 
                <td>
                <t:label t:for="password"/>:
                </td>
                <td>
                    <input type="text" t:type="passwordfield"  t:id="password" 
                    t:value="password" t:validate="required"/>
                    </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="submit" value="Log In"/>
                </td>
            </tr>               
    </table>    
    </t:form>

更換

<t:form id="loginForm">

<t:form t:id="loginForm">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM