java - 我想在 Tapestry 页面中发布包含酒店的列表,但此错误反复出现

标签 java tapestry

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

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),请随时询问。谢谢!

      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;}
} 

酒店等级是这样的:---------------------------------------------------- -------------

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;
}
}

最佳答案

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

关于java - 我想在 Tapestry 页面中发布包含酒店的列表,但此错误反复出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48024507/

相关文章:

java - 字节 z[] = 新字节[5]; - 这是什么意思?

java - DateTimeFormatter.parseLocalDate 抛出 UnsupportedOperationException

java - 在 Tapestry 中选择名称而不是 ID

tomcat - Tapestry + JaxB 冲突

java - 使用注释保护 Tapestry 事件处理程序

java - Tapestry 5 - 编辑字符串数组列表

java - SNMP4J : What does "Inconsistent naming used" error mean?

java - @JmsListener 持久订阅问题

java - 如何使用 Android Studio 删除 JsonArray 中的反斜杠 ("\"")?

java - 在 Tapestry 中渲染一个请求参数