首页 > 解决方案 > 我不能使用 varStatus 值来获取 p:repeat 中的索引

问题描述

我我的 xhtml 代码是这样的:

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:p="http://primefaces.org/ui"
     xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:h="http://xmlns.jcp.org/jsf/html">

    <p:column headerText="Student">
              <p:repeat value="#{student.convertList()}" var="item" varStatus="index">
                    <h:outputText value="#{item.nameStudent}" id="#{index}" />
               </p:repeat>
            </p:column>

使用该方法student.converList()是因为我的学生在一个集合中,所以我需要在列表中转换集合:

public List<Student> convertList() {    
        return new ArrayList<Autori>(this.setStudent);
    }

它给了我:

不允许使用空 id 属性

任何人都可以帮助我吗?

标签: jsfjsf-2.2

解决方案


推荐阅读