我在处理BeanEditForm组件时遇到了一些问题。 你看,一切都很好(它显示它应该),只要我不使用参数化的构造函数为我的bean类(和我需要他们)。这是我Bean类看起来像:Tapestry 5 BeanEditForm组件故障
public class Celebrity {
private String firstName;
private String lastName;
private long ID;
private Date dateOfBirth;
private Occupation occupation;
private String biography;
private boolean birthDateVerified;
public Celebrity() {
}
public Celebrity(String firstName, String lastName, Date dateOfBirth, Occupation occupation, String biography, boolean birthDateVerified) {
this.firstName = firstName;
this.lastName = lastName;
this.dateOfBirth = dateOfBirth;
this.occupation = occupation;
this.biography = biography;
this.birthDateVerified = birthDateVerified;
}
public Celebrity(String firstName, String lastName, Date dateOfBirth, Occupation occupation) {
this.firstName = firstName;
this.lastName = lastName;
this.dateOfBirth = dateOfBirth;
this.occupation = occupation;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public long getID() {
return ID;
}
public void setID(long ID) {
this.ID = ID;
}
public Date getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public Occupation getOccupation() {
return occupation;
}
public void setOccupation(Occupation occupation) {
this.occupation = occupation;
}
/**
* @return the biography
*/
public String getBiography() {
return biography;
}
public void setBiography(String biography) {
this.biography = biography;
}
public boolean getBirthDateVerified() {
return birthDateVerified;
}
public void setBirthDateVerified(boolean birthDateVerified) {
this.birthDateVerified = birthDateVerified;
}
}
这是我的挂毯模板:AddNewCelebrity.tml
<html t:type="layout" title="Celebrity Details"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
xmlns:p="tapestry:parameter">
<head>
<Title>Adding new celebrety</Title>
</head>
<body>
<t:beaneditform t:id="celebrity"/>
</body>
</html>
及其Java类:
public class AddNewCelebrity {
@Persist
private Celebrity celebrity;
public Celebrity getCelebrity() {
return celebrity;
}
public void setCelebrity(Celebrity celeb) {
this.celebrity = celeb;
}
}
这是错误,我当我不评论我的参数化构造函数时从挂毯获得:
SetupRender中的渲染队列错误[AddNewCelebrity:celebrity.editor]:异常实例化com.celebreties.celebs.model.Celebrity(对于组件'AddNewCelebrity:celebrity.editor'):错误调用构造函数com.celebreties.celebs.model。名人(字符串,字符串,日期,职业,字符串,布尔)(在Celebrity.java:29)(用于服务'BeanModelSource'):没有服务实现接口java.lang.String。
我用挂毯5.2.4和Tomcat 6.0.32
请给些指导我该怎么办。
感谢Martin,这完全解决了我的问题。我专注于寻找某种模型类,它可以作为BeanEditForm中的模型组件插入。这并不是浪费时间,但这是更优雅的解决方案。 – 2011-03-20 14:35:21