开发者

Cross-form validation issue tapestry

开发者 https://www.devze.com 2023-03-06 22:49 出处:网络
I really new in Java....i work some research in java using tool Tapestryframework... I have some problem with exception when i calling@Component \"Form\"...tapestry throws me exception :

I really new in Java....i work some research in java using tool Tapestry framework... I have some problem with exception when i calling @Component "Form"...tapestry throws me exception :

Embedded component(s) loginForm are defined within component class com.fit.pages.Login (or a super-class of Login), but are not present in the component template (classpath:com/fit/pages/Login.tml).

context eventType

activate

org.apache.tapestry5.ioc.internal.OperationException

Embedded component(s) loginForm are defined within component class com.fit.pages.Login (or a super-class of Login), but are not present in the component template (classpath:com/fit/pages/Login.tml).

trace

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

my code looks something like this

public class 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;
}

and code in login.tml :

Please log in:

    <t:form id="loginForm">
    <table>
            <tr>
                <td>
                <t:label t:for="userName"/>:
                </td>
                <td>
                    <input type="text" t:type="textfield"  t:id="userNa开发者_如何学JAVAme" 
                    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>


replace

<t:form id="loginForm">

with

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

精彩评论

暂无评论...
验证码 换一张
取 消