Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用Netbeans在datatable中使用集合_Java_Netbeans_Collections_Datatable - Fatal编程技术网

Java 如何使用Netbeans在datatable中使用集合

Java 如何使用Netbeans在datatable中使用集合,java,netbeans,collections,datatable,Java,Netbeans,Collections,Datatable,大家好,我正在写一个项目,以允许在页面上单独显示课程表中的所有特定课程。所以所有的高尔夫课程都在一个高尔夫页面上,所有的网球课程都在另一个页面上,等等。下面是我用过的豆子 //collects the lessons for specific sport number public Collection<Lesson> getLessonForSpecificSport(){ Map<String, String> parameter=FacesC

大家好,我正在写一个项目,以允许在页面上单独显示课程表中的所有特定课程。所以所有的高尔夫课程都在一个高尔夫页面上,所有的网球课程都在另一个页面上,等等。下面是我用过的豆子

    //collects the lessons for specific sport number
    public Collection<Lesson> getLessonForSpecificSport(){
    Map<String, String> parameter=FacesContext.getCurrentInstance().
            getExternalContext().getRequestParameterMap();

    //parse the sport=x from the url to an integer
    int sportNumber = Integer.parseInt(parameter.get("sport"));

    //if sport number is equal to zero, display all lessons
    if (sportNumber==0)
    {
        return (Collection<Lesson>) this.getLessonList();
    }
    //else display the lessons corresponding to the value within sportNumber
    else
    {
        //return the sport.getLessonCollection() result
        return em.find(Sport.class, sportNumber).getLessonCollection(); 
    }
}
//收集特定运动项目编号的课程
公共集合GetLessonForSpecificPort(){
映射参数=FacesContext.getCurrentInstance()。
getExternalContext().getRequestParameterMap();
//将sport=x从url解析为整数
int sportNumber=Integer.parseInt(参数.get(“sport”));
//如果运动编号等于零,则显示所有课程
如果(sportNumber==0)
{
返回(集合)this.getLessonList();
}
//否则显示与sportNumber中的值对应的课程
其他的
{
//返回sport.getLessonCollection()结果
返回em.find(Sport.class,sportNumber).getLessonCollection();
}
}
我想知道的是如何使用dataTable在页面上呈现它,最新的尝试是这样的,但当我运行Netbeans时,页面上什么也没有出现

  <h:dataTable value="#{getLessonForSpecificSport.lesson}" var="item">
  <h:column>
  <f:facet name="header">
       Class no
  </f:facet>
  <f:param name="sportno" value="#{lesson.sportno}" />                      
  </h:column>
  </h:dataTable>

类别号

您可能希望执行以下操作:

<h:dataTable value="#{listBean.lessonForSpecificSport}" var="lesson">
  <h:column>
     <f:facet name="header">
        Class no
     </f:facet>
     <h:outputText value="#{lesson.sportno}" />                      
  </h:column>
</h:dataTable>

类别号


类别号
#{lesson.sportno}”
假设类
Lesson
中有一个名为
getSportno()
的方法,并且支持bean的名称是
listBean

请注意,如果调用
Lesson
方法
getSportNo()
,则应在数据表中使用
{Lesson.sportNo}
。即,方法名称区分大小写,并且只有get前缀后的第一个字母使用小写

<h:dataTable value="#{listBean.lessonForSpecificSport}" var="lesson">
  <h:column>
    <f:facet name="header">
       Class no
    </f:facet>
    #{lesson.sportno}"                    
  </h:column>
</h:dataTable>