类mypack.pages.User已被转换,可能无法直接实例化

时间:2015-11-22 16:17:16

标签: java tapestry

我正在尝试根据此Tutorial显示带有挂毯的网格,但我收到此错误Class mypack.pages.User has been transformed and may not be directly instantiated 这些是我的课程用户

    public class User {     
        @NonVisual
        private long id;

        private String firstName;

        private String lastName;

        private int age;

        public long getId() { return id; }

        public void setId(long id) { this.id = id; }

        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 int getAge() { return age; }

        public void setAge(int age) { this.age = age; }

        public User(long id, String firstName, String lastName, int age) {
            super();
            this.id = id;
            this.firstName = firstName;
            this.lastName = lastName;
            this.age = age;
        }
}

Bellilpage.java

public class Bellilpage {
     @Property
        private User user;

    public List<User> getUsers() { 

         List<User> dd= new ArrayList<User>();
         for(int x=0;x<1;x++)
         {
             Random rand = new Random(); 
             long d= rand.nextInt(50);
            User myuser = new User(d, "Name N° "+d, "lastName N "+d, (int) (d+15));

        dd.add(myuser);
         }

         return dd; }

}

最后这就是我尝试在网页中显示网格的方式 的 Bellilpage.tml

<html t:type="layout" title="tapestrythetest Index"
      t:sidebarTitle="Framework Version"
      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
      xmlns:p="tapestry:parameter">
    <!-- A Zone is a component that can be updated in place, triggered by other components. -->
    <t:zone t:id="zone">
      <h1>List Users</h1>

        <t:grid source="users"  row="user">
            <p:lastNameCell>
           ${user.lastname} 
            </p:lastNameCell>

        </t:grid>
    </t:zone>

    <p:sidebar>

    </p:sidebar>

</html>

为什么我在打开Bellilpage.tml时会出现此错误?

1 个答案:

答案 0 :(得分:2)

您收到错误是因为 mypack.pages 是T5控件包。将您的用户类移至其他包,例如到mypack.entities。有关Component Classes的更多信息,特别是“组件包”部分。