openfaces数据表问题
我尝试构建一个非常简单的页面,其中包含 openfaces 数据表组件。
我尝试为其启用分页。我已经按照开发人员指南完成了指令
,但是当我在后台 bean 中获取这两个变量时,pageStart
始终为零!
这是我的 .xhtml 文件
<?xml version="1.0" encoding="UTF-8"?>
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:o="http://openfaces.org/"
xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en">
<h:head>
<title>My Facelets Page</title>
<meta http-equiv="keywords" content="enter,your,keywords,here" />
<meta http-equiv="description"
content="A short description of this page." />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="styles.css" />
</h:head>
<h:body>
<div id="Demo" class="content-inner-wrapper">
<f:view>
<h:form id="form">
<o:dataTable id="citiesTable"
value="#{testBean.lazyModel}"
var="city"
customDataProviding="true"
pageSize="15"
totalRowCount="#{testBean.count}"
rowDataByKey="#{testBean.rowByKey}"
rowKey="#{city.id}"
styleClass="cities">
<o:singleRowSelection/>
<o:columnReordering/>
<f:facet name="columnMenu">
<o:columnMenu/>
</f:facet>
<o:column id="name" header="City" sortingExpression="#{city.cityTitle}"
bodyStyle="padding-left: 10px;">
<f:facet name="subHeader">
<o:inputTextFilter expression="name"/>
</f:facet>
<h:outputText value="#{city.cityTitle}"/>
</o:column>
<o:column id="population" header="Population" sortingExpression="#{city.cityCode}"
style="width: 20%;"
bodyStyle="text-align: right; padding-right: 15px;">
<f:facet name="subHeader">
<o:comboBoxFilter expression="population" options="#{CitiesList.ranges}"/>
</f:facet>
<h:outputText value="#{city.cityCode}">
<f:convertNumber type="number"/>
</h:outputText>
</o:column>
<f:facet name="below">
<h:panelGroup>
<o:dataTablePaginator id="paginator"
style="margin-left: 240px; margin-top: 10px;"
/>
<h:outputText value="Event log:"
style="margin-top: 10px; margin-bottom: 5px; border-bottom: 1px solid black;"/>
</h:panelGroup>
</f:facet>
</o:dataTable>
</h:form>
</f:view>
</div>
</h:body>
</html>
,这是我的 back bean:
package backbeans;
import java.util.List;
import javax.ejb.EJB;
import order.TblBaseCities;
import order.TblBaseCitiesFacadeLocal;
import org.openfaces.util.Faces;
public class TestBean {
@EJB
TblBaseCitiesFacadeLocal cities;
public List<TblBaseCities> getLazyModel(){
int pageStart = Faces.var("pageStart", Integer.class);
return cities.findAll(pageStart,Faces.var("pageSize",Integer.class));
}
public int getCount(){
return cities.findAll().size();
}
public TblBaseCities getRowByKey() {
Integer key = Faces.var("rowKey", Integer.class);
return cities.findById(key);
}
}
我正在使用 openfaces 3.0、myfaces 2.0.4 和 weblogic 10.3.3 服务器,
提前致谢
i have tried to build a very simple page that includes openfaces datatable component.
i have tried to enable pagination for it. i have done the instruction just like its
developer's guide, but when i get these two variables in my back bean, the pageStart is
always is zero!
this is my .xhtml file
<?xml version="1.0" encoding="UTF-8"?>
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:o="http://openfaces.org/"
xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en">
<h:head>
<title>My Facelets Page</title>
<meta http-equiv="keywords" content="enter,your,keywords,here" />
<meta http-equiv="description"
content="A short description of this page." />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="styles.css" />
</h:head>
<h:body>
<div id="Demo" class="content-inner-wrapper">
<f:view>
<h:form id="form">
<o:dataTable id="citiesTable"
value="#{testBean.lazyModel}"
var="city"
customDataProviding="true"
pageSize="15"
totalRowCount="#{testBean.count}"
rowDataByKey="#{testBean.rowByKey}"
rowKey="#{city.id}"
styleClass="cities">
<o:singleRowSelection/>
<o:columnReordering/>
<f:facet name="columnMenu">
<o:columnMenu/>
</f:facet>
<o:column id="name" header="City" sortingExpression="#{city.cityTitle}"
bodyStyle="padding-left: 10px;">
<f:facet name="subHeader">
<o:inputTextFilter expression="name"/>
</f:facet>
<h:outputText value="#{city.cityTitle}"/>
</o:column>
<o:column id="population" header="Population" sortingExpression="#{city.cityCode}"
style="width: 20%;"
bodyStyle="text-align: right; padding-right: 15px;">
<f:facet name="subHeader">
<o:comboBoxFilter expression="population" options="#{CitiesList.ranges}"/>
</f:facet>
<h:outputText value="#{city.cityCode}">
<f:convertNumber type="number"/>
</h:outputText>
</o:column>
<f:facet name="below">
<h:panelGroup>
<o:dataTablePaginator id="paginator"
style="margin-left: 240px; margin-top: 10px;"
/>
<h:outputText value="Event log:"
style="margin-top: 10px; margin-bottom: 5px; border-bottom: 1px solid black;"/>
</h:panelGroup>
</f:facet>
</o:dataTable>
</h:form>
</f:view>
</div>
</h:body>
</html>
and this is my back bean:
package backbeans;
import java.util.List;
import javax.ejb.EJB;
import order.TblBaseCities;
import order.TblBaseCitiesFacadeLocal;
import org.openfaces.util.Faces;
public class TestBean {
@EJB
TblBaseCitiesFacadeLocal cities;
public List<TblBaseCities> getLazyModel(){
int pageStart = Faces.var("pageStart", Integer.class);
return cities.findAll(pageStart,Faces.var("pageSize",Integer.class));
}
public int getCount(){
return cities.findAll().size();
}
public TblBaseCities getRowByKey() {
Integer key = Faces.var("rowKey", Integer.class);
return cities.findById(key);
}
}
i am using openfaces 3.0, myfaces 2.0.4 and weblogic 10.3.3 server
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎忘记放置 DataTablePaginator 组件本身。您应该将其放置在“上方”和/或“下方”方面。只需确保显式指定分页器的 id 即可使其正常运行。
It seems that you have forgot to place the DataTablePaginator component itself. You should place it in "above" and/or "below" facet. Just make sure that paginator's id is specified explicitly for it to function properly.