我想在挂毯页面上发布带有酒店的列表,但这个错误一遍又一遍地出现

时间:2017-12-29 15:02:59

标签: 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>
&#13;
&#13;
&#13;

Java类 如果您需要任何课程,请随时提出。谢谢!

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

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

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