首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >openfaces数据表问题

openfaces数据表问题
EN

Stack Overflow用户
提问于 2011-04-30 19:41:41
回答 1查看 1.3K关注 0票数 0

我曾尝试构建一个包含openfaces datatable组件的非常简单的页面。

我已经尝试为它启用分页。我已经按照它的指示去做了

但是当我在back bean中获得这两个变量时,pageStart是

总是为零!

这是我的.xhtml文件

代码语言:javascript
复制
   <?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:

代码语言:javascript
复制
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服务器

提前感谢

EN

回答 1

Stack Overflow用户

发布于 2011-05-01 04:55:47

您似乎忘记了放置DataTablePaginator组件本身。你应该把它放在“上方”和/或“下方”方面。只需确保显式指定了分页器的id,以使其正常工作。

代码语言:javascript
复制
<o:dataTable ...>
  <f:facet name="above">
    <o:dataTablePaginator id="paginator"/>
  </f:facet>
  ...
</o:dataTable>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5841487

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档