跨表单验证问题挂毯
我对 Java 真的很陌生......我使用 Tapestry 框架工具对 Java 进行了一些研究...... 当我调用@Component“Form”时,我遇到一些异常问题... Tapestry 抛出异常:
嵌入式组件loginForm在组件类com.fit.pages.Login(或超类)中定义Login),但不存在于组件模板 (classpath:com/fit/pages/Login.tml) 中。
eventType
activate
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**
我的代码看起来像这样
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;
}
和 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>
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="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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
替换
为
replace
with