primefaces数据表查询两次

时间:2015-12-06 20:59:49

标签: primefaces jsf-2.2

运行一个简单的primefaces p:datatable正在执行两次查询。一个h:数据表只有一次。

知道为什么吗?

<h:dataTable id="table1" value="#{employees.records}" var="record">
			<h:column>
				<f:facet name="header">
					<h:outputText value="ID" />
				</f:facet>
				<h:outputText value="#{record.id}" />
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="First Name" />
				</f:facet>
				<h:outputText value="#{record.firstName}" />
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Last Name" />
				</f:facet>
				<h:outputText value="#{record.lastName}" />
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Company Name" />
				</f:facet>
				<h:outputText value="#{record.company.name}" />
			</h:column>
		</h:dataTable>

正在运行一次查询。控制台上的输出:

Hibernate: select employee0_.ID as ID19_, employee0_.CompanyId as CompanyId19_, employee0_.EMAIL as EMAIL19_, employee0_.FIRSTNAME as FIRSTNAME19_, employee0_.LASTNAME as LASTNAME19_, employee0_.PASSWORD as PASSWORD19_, employee0_.PHONE_INTERN as PHONE6_19_, employee0_.USERNAME as USERNAME19_,  concat(employee0_.FIRSTNAME, ' ', employee0_.LASTNAME)  as formula0_ from EMPLOYEE employee0_

运行简单的primefaces DataTable运行两次查询:

		<p:dataTable id="employees" var="employee"
			value="#{employees.records}">

			<p:column headerText="Id">
				<h:outputText value=" #{employee.id}" />
			</p:column>

			<p:column headerText="First Name">
				<h:outputText value=" #{employee.firstName}" />
			</p:column>

			<p:column headerText="Last Name">
				<h:outputText value="#{employee.lastName}" />
			</p:column>

			<p:column headerText="Company Name">
				<h:outputText value=" #{employee.company.name}" />
			</p:column>

		</p:dataTable>

控制台:

Hibernate: select employee0_.ID as ID19_, employee0_.CompanyId as CompanyId19_, employee0_.EMAIL as EMAIL19_, employee0_.FIRSTNAME as FIRSTNAME19_, employee0_.LASTNAME as LASTNAME19_, employee0_.PASSWORD as PASSWORD19_, employee0_.PHONE_INTERN as PHONE6_19_, employee0_.USERNAME as USERNAME19_,  concat(employee0_.FIRSTNAME, ' ', employee0_.LASTNAME)  as formula0_ from EMPLOYEE employee0_
Hibernate: select employee0_.ID as ID19_, employee0_.CompanyId as CompanyId19_, employee0_.EMAIL as EMAIL19_, employee0_.FIRSTNAME as FIRSTNAME19_, employee0_.LASTNAME as LASTNAME19_, employee0_.PASSWORD as PASSWORD19_, employee0_.PHONE_INTERN as PHONE6_19_, employee0_.USERNAME as USERNAME19_,  concat(employee0_.FIRSTNAME, ' ', employee0_.LASTNAME)  as formula0_ from EMPLOYEE employee0_

怎么回事?

Tomcat 7,jsf 2.2,PF 5.3

谢谢,Duesentrieb

添加更多代码:

<h:form id="frmDataTable">
			<p:dataTable id="employees" var="employee"
				value="#{employees.records}">

				<p:column headerText="Id">
					<h:outputText value=" #{employee.id}" />
				</p:column>

				<p:column headerText="First Name">
					<h:outputText value=" #{employee.firstName}" />
				</p:column>

				<p:column headerText="Last Name">
					<h:outputText value="#{employee.lastName}" />
				</p:column>

				<!-- p:column headerText="Company Name">
					<h:outputText value=" #{employee.company.name}" />
				</p:column-->

				<p:column style="width:32px;text-align: center">
					<p:commandButton icon="ui-icon-search" title="View">
				
					</p:commandButton>
				</p:column>

			</p:dataTable>
		</h:form>


		<h:form id="dlgDataTable">

			<p:dialog header="Employee Info" id="dlgEmployee"
				widgetVar="dlgEmployee" modal="false" showEffect="fade"
				hideEffect="fade" resizable="false">

				<p:outputPanel id="employeeDetail" style="text-align:center;">

					<p:panelGrid columns="2" columnClasses="label,value">
						<f:facet name="header">Employee</f:facet>

						<h:outputText value="Id:" />
				</p:outputPanel>

			</p:dialog>

		</h:form>

我现在用p:对话框扩展了p:datatable。我甚至没有更新记录或者什么都没有,每次点击按钮12都会执行查询。

这可能不对 - 我做错了什么?

谢谢!

0 个答案:

没有答案