我的课程结构如下:
@Entity
@Table(name = "Tiket")
public class Tiket {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "TICKET_ID")
private int tiketID;
@Basic(optional = false)
@Column(name = "TICKET_DRAW_ID")
private String tiketDrawID;
@Basic(optional = false)
@Column(name = "TICKET_DATE")
@Temporal(TemporalType.TIMESTAMP)
private Date ticketDate;
@Basic(optional = false)
@Column(name = "TICKET_DRAW_TYPE")
@Enumerated(EnumType.STRING)
private TipDrawTiketa ticketDrawTicket;
@Basic(optional = false)
@Column(name = "TICKET_SERIAL")
private String ticketSerial;
@Basic(optional = false)
@Column(name = "TICKET_NUMBER")
private String ticketNumber;
@Basic(optional = false)
@Column(name = "TICKET_STATUS_OF_A_TICKET")
@Enumerated(EnumType.STRING)
private TiketStatus ticketStatus;
@Basic(optional = false)
@Column(name = "TICKET_PRICE")
private int ticketPrice;
public Tiket(int tiketID, String tiketDrawID, Date tiketDatum, TipDrawTiketa tiketDrawTiketa, String tiketSerija, String tiketBroj, TiketStatus tiketStatusTiketa, int tiketCijena) {
this.tiketID = tiketID;
this.tiketDrawID = tiketDrawID;
this.ticketDate = tiketDatum;
this.ticketDrawTicket = tiketDrawTiketa;
this.ticketSerial = tiketSerija;
this.ticketNumber = tiketBroj;
this.ticketStatus = tiketStatusTiketa;
this.ticketPrice = tiketCijena;
}
public Tiket(String tiketDrawID, Date tiketDatum, TipDrawTiketa tiketDrawTiketa, String tiketSerija, String tiketBroj, TiketStatus tiketStatusTiketa, int tiketCijena) {
this.tiketDrawID = tiketDrawID;
this.ticketDate = tiketDatum;
this.ticketDrawTicket = tiketDrawTiketa;
this.ticketSerial = tiketSerija;
this.ticketNumber = tiketBroj;
this.ticketStatus = tiketStatusTiketa;
this.ticketPrice = tiketCijena;
}
public Tiket() {
}
/**
* @return the tiketID
*/
public int getTiketID() {
return tiketID;
}
/**
* @param tiketID the tiketID to set
*/
public void setTiketID(int tiketID) {
this.tiketID = tiketID;
}
/**
* @return the tiketDrawID
*/
public String getTiketDrawID() {
return tiketDrawID;
}
/**
* @param tiketDrawID the tiketDrawID to set
*/
public void setTiketDrawID(String tiketDrawID) {
this.tiketDrawID = tiketDrawID;
}
/**
* @return the ticketDate
*/
public Date getTicketDate() {
return ticketDate;
}
/**
* @param ticketDate the ticketDate to set
*/
public void setTicketDate(Date ticketDate) {
this.ticketDate = ticketDate;
}
/**
* @return the ticketDrawTicket
*/
public TipDrawTiketa getTicketDrawTicket() {
return ticketDrawTicket;
}
/**
* @param ticketDrawTicket the ticketDrawTicket to set
*/
public void setTicketDrawTicket(TipDrawTiketa ticketDrawTicket) {
this.ticketDrawTicket = ticketDrawTicket;
}
/**
* @return the ticketSerial
*/
public String getTicketSerial() {
return ticketSerial;
}
/**
* @param ticketSerial the ticketSerial to set
*/
public void setTicketSerial(String ticketSerial) {
this.ticketSerial = ticketSerial;
}
/**
* @return the ticketNumber
*/
public String getTicketNumber() {
return ticketNumber;
}
/**
* @param ticketNumber the ticketNumber to set
*/
public void setTicketNumber(String ticketNumber) {
this.ticketNumber = ticketNumber;
}
/**
* @return the ticketStatus
*/
public TiketStatus getTicketStatus() {
return ticketStatus;
}
/**
* @param ticketStatus the ticketStatus to set
*/
public void setTicketStatus(TiketStatus ticketStatus) {
this.ticketStatus = ticketStatus;
}
/**
* @return the ticketPrice
*/
public int getTicketPrice() {
return ticketPrice;
}
/**
* @param ticketPrice the ticketPrice to set
*/
public void setTicketPrice(int ticketPrice) {
this.ticketPrice = ticketPrice;
}
现在我想列出一个列表,不仅列出了这个类,还搜索了它的功能。我尝试在java文件中使用Stitch component Observe,如下所示:
public class ListTiket {
// parametri klase
@Inject
private BiznisLogika biznisLogika;
@Property
private List<Tiket> listaTiketa;
@InjectComponent
private Zone zonaZaTikete;
void setupRender() {
listaTiketa = getTikete();
}
/**
* This event is fired by the observe mixin
*/
Block onFilter(String ticketSerial, String ticketNumber) {
//Date parsedDatum = parseDate(datumZaPromjenu);
List<Tiket> filtered = new ArrayList<Tiket>();
for (Tiket tiketaa : getTikete()) {
//boolean include = datumZaPromjenu == null || phone.name.toLowerCase().contains(name.toLowerCase());
boolean include = ticketSerial == null || ticketSerial.equals(tiketaa.getTicketSerial());
//tiketaa.getTicketSerial().toLowerCase().contains(ticketSerial.toLowerCase());
include &= ticketNumber == null || ticketNumber.equals(tiketaa.getTicketNumber());
if (include) {
filtered.add(tiketaa);
}
}
listaTiketa = filtered;
return zonaZaTikete.getBody();
}
/*
@CommitAfter
@SuppressWarnings("unchecked")*/
public List<Tiket> getTikete() {
return biznisLogika.izlistajSveTikete();
}
}
并在tml文件中:
<div class="container_12" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter">
<t:form autofocus="literal:true">
<div class="alert alert-info">Select some filter values to filter the list of tickets</div>
${message:datum} <t:textfield t:id="ticketSerial" t:mixins="stitch/observe" value="literal:" clientEvent="keyup" event="filter"
zone="zonaZaTikete" context="literal:ticketSerial" fields="['ticketSerial','ticketNumber']" /><br />
<t:any element="select" t:id="ticketNumber" t:mixins="stitch/observe" clientEvent="change" event="filter"
zone="zonaZaTikete" context="literal:ticketNumber" fields="['ticketSerial','ticketNumber']">
<option value="">All</option>
<option value="TICKET1">TICKET1</option>
<option value="TICKET2">TICKET2</option>
<option value="TICKET3">TICKET3</option>
</t:any>
</t:form>
<t:zone t:id="zonaZaTikete">
<t:grid source="listaTiketa" >
<p:empty>
<p>Nothing to display.</p>
</p:empty>
</t:grid>
</t:zone>
</div>
但是它只返回完整列表。有人可以帮助我如何从数据库中删除拉出列表?
提前致谢。