我想 post 挂毯页面中的酒店列表,但此错误反复出现

I want to post a lists with hotels in a tapestry page but this error appears over and over

我做了一些更改,但仍然有错误:

BeginRender[ShowAll:grid.rows.gridcell] 中的渲染队列错误:com.mycompany.licenta.pages.Hotel 无法转换为 com.mycompany.licenta.pages.Hotel

TML 页面:

<html t:type="layout" title="Show All"
      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
      xmlns:p="tapestry:parameter">

   <head>
   <title>Lista Hoteluri</title>
  </head>
   <body>
     <t:grid t:source="allHotels"/>

<br/>
      <a href="#" t:type="PageLink" t:page="Index">
      Back to the Start Page</a>
    </body>

</html>

Java Class 如果您需要任何 classes,请随时询问。谢谢!

      package com.mycompany.licenta.pages;
import org.apache.tapestry5.annotations.SessionState;
import com.mycompany.licenta.util.User;
import com.mycompany.licenta.data.ListaHoteluri;
import com.mycompany.licenta.pages.Hotel;
import com.mycompany.licenta.data.IDataSource;
import java.util.List;
import java.text.Format;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.OnEvent;
/**
 *
 * @author Alina
 */ 
public class ShowAll {
    @SessionState
private User user;
private boolean userExists;

@SessionState
private IDataSource dataSource;

@InjectPage
private Details detailsPage;
private Hotel hotel;
String onActivate()
{
    if(!userExists) return "Index";
    return null;
}

//@OnEvent(component="detailsLink")
Object onShowDetails(long id)  
       {
Hotel hotel = dataSource.getHotelById(id);
detailsPage.setHotel(hotel);
return detailsPage;
     }
public List<Hotel>getAllHotels()
{
return dataSource.getAllHotels();
}
public Hotel getHotel()
{
return hotel;
} 
public void setHotel(Hotel hotel)
{
this.hotel = hotel;
}

//Object onActivate()
//{if (!userExists) return Index.class; return null;}
} 

酒店class是这样的:-------------------------------- ------------------

package com.mycompany.licenta.pages;

/**
 *
 * @author Alina
 */
public class Hotel {
   private long id;
   private String numeHotel;
   private String adresaHotel;
   private float notaGenerala;
   private int numarRecenzii;
   private int numarVizualizari;

   public Hotel()
           { 

           }
public Hotel(String numeHotel,String adresaHotel,float notaGenerala,int numarRecenzii,
        int numarVizualizari)
{
    this.numeHotel=numeHotel;
    this.adresaHotel=adresaHotel;
    this.notaGenerala=notaGenerala;
    this.numarRecenzii=numarRecenzii;
    this.numarVizualizari=numarVizualizari;
}

public String getNumeHotel()
{
return numeHotel;
}
public void setNumeHotel(String numeHotel)
{
this.numeHotel = numeHotel;
}
public String getAdresaHotel()
{
return adresaHotel;
}
public void setAdresaHotel(String adresaHotel)
{
this.adresaHotel = adresaHotel;
}
public float getNotaGenerala()
{
return notaGenerala;
}

public void setNotaGenerala(float notaGenerala)
{
this.notaGenerala = notaGenerala;
}
public int getNumarRecenzii()
{
return numarRecenzii;
}
public void setNumarRecenzii(int numarRecenzii)
{
this.numarRecenzii= numarRecenzii;
}
public int getNumarVizualizari()
{
return numarVizualizari;
}
public void setNumarVizualizari(int numarVizualizari)
{
    this.numarVizualizari=numarVizualizari;
}
public long getId()
{
    return id;
}
public void setId(long id)
{
    this.id=id;
}
}

注释掉 ShowAll.java 中的 @InjectPage 行。我认为问题是那个无关紧要的注释告诉 Tapestry 对您的酒店进行字节码更改 属性 而您不想要。

为什么您的 Hotel class 似乎不是有效的 Tapestry 页面,但在 pages 包中? pages 是为有效 Tapestry 页面 classes 保留的特殊包。将模型 class 移动到 pages 包之外的包(不要将其移动到子包,尝试类似 com.mycompany.licenta.data 的东西)。还要确保您没有同时拥有模型 class 和名为 Hotel 的页面,并且您正在将错误的 Hotel 导入 ShowAll 页面。