[英]Cross-form validation issue tapestry
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 : 我是Java的新手....我使用工具Tapestry框架在java中进行一些研究...当我调用@Component“Form”时,我有一些异常问题... ... tapestry抛出异常:
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). 嵌入式组件loginForm在组件类com.fit.pages.Login(或Login的超类)中定义,但在组件模板中不存在(classpath:com / fit / pages / Login.tml)。
context eventType context eventType
activate 启用
org.apache.tapestry5.ioc.internal.OperationException 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). 嵌入式组件loginForm在组件类com.fit.pages.Login(或Login的超类)中定义,但在组件模板中不存在(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 : 和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="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>
replace 更换
<t:form id="loginForm">
with 同
<t:form t:id="loginForm">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.