gpt4 book ai didi

sorting - Primefaces 数据表排序和过滤在 rowSelect 之前不起作用

转载 作者:行者123 更新时间:2023-12-02 20:57:56 27 4
gpt4 key购买 nike

我知道这个问题可能会重复,但我真的找不到我的问题的解决方案;我的问题是,除非我在关闭对话框后单击任何行以显示详细信息对话框,否则排序和过滤等数据表功能无法正常工作,所有“排序、过滤”都正常工作并按预期进行。

这是我的代码:Bean.java

@ViewScoped
public class HomeBean implements Serializable {

private List<Ticket> filteredTickets;
private List<Ticket> tickets;
private Ticket selectedTicket;
private Ticket[] selectedTickets;

public HomeBean() {
super();
}

@PostConstruct
public void init() {
getData();
}

private void getData() {
TicketFacade service;
service = TicketFacade.getInstance();
try {
tickets = service.selectTickets();
} catch (Exception e) {
logger.error(Utilities.printStackTrace(e));
}
}
// setter & getters

@PreDestroy
public void finalize() {
logger.debug("@PreDestroy");
}
}

这是 xhtml

    <?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">

<f:view contentType="text/html">
<h:head>
<f:facet name="first">
<meta content='text/html; charset=UTF-8' http-equiv="Content-Type" />
<title>Home Page</title>
</f:facet>

<script type="text/javascript">
window.history.forward();
function noBack() {
window.history.forward();
}
</script>
</h:head>

<h:body id="body-view" onload="noBack();"
onpageshow="if (event.persisted) noBack();" onunload="">
<f:view locale="#{userManager.locale}">
<h:form id="Ticket">
<p:dataTable var="ticket" value="#{homeBean.tickets}"
rowKey="#{ticket.id}" paginator="true" rows="15"
selection="#{homeBean.selectedTicket}" selectionMode="single"
filteredValue="#{homeBean.filteredTickets}" id="ticketsTable"
emptyMessage="#{lbl.noTicketsFound}"
style="margin-bottom:10px;margin-top:10px;">
<p:ajax event="rowSelect" update=":Ticket:display"
oncomplete="ticketDialog.show()" />

<f:facet name="header">#{lbl.listOfTickets}</f:facet>

<p:column headerText="#{lbl.tblId}" sortBy="#{ticket.id}"
filterBy="#{ticket.id}" id="id">
<h:outputLink value="#{edit.xhtml?id=#{ticket.id}">#{ticket.id}</h:outputLink>

</p:column>

<p:column headerText="#{lbl.tblTitle}" sortBy="#{ticket.title}"
filterBy="#{ticket.title}" id="title"> #{ticket.title}
</p:column>

</p:dataTable>

<p:dialog header="#{lbl.moreTicketDetails}" widgetVar="ticketDialog"
resizable="true" width="500" showEffect="explode"
hideEffect="explode" closable="true" draggable="true">

<h:panelGrid id="display" columns="2" cellpadding="4"
dir="#{lbl.dir}">
<h:outputText for="shortDescription"
value="#{lbl.shortDescription}" />
<h:outputText id="shortDescription"
value="#{homeBean.selectedTicket.shortDescription}" />

<h:outputText for="callCenterList" value="#{lbl.callcenters}" />
<h:outputText id="callCenterList"
value="#{homeBean.selectedCallCenters}">
</h:outputText>
</h:panelGrid>
</p:dialog>
</h:form>
</f:view>
</h:body>
</f:view>
</html>

最佳答案

不久前我在屏幕上看到过类似的问题。当页面未完全呈现时,排序和过滤不会发生。出于测试目的,您可以尝试删除 java 脚本并尝试。另一种调试方法是使用 chrome 按 f12 并查看网络选项卡以查找 ajax 调用。希望这会有所帮助。

关于sorting - Primefaces 数据表排序和过滤在 rowSelect 之前不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16252997/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com