1

How to generate a dynamic data table with dynamic rows and columns? The rows and columns are dynamic based on backend values. The 2,3,4 columns will be a list of semester-subject combination list to store the selected value.

I know this can be achieved with primefaces. But is there a way to not use any libraries but achieve this with jsf 2.2?

My code is generating the semester-subject list in all one row.

enter image description here

<table>
    <thead>
        <tr>
        <th>Enrollment</th>
            <c:forEach items="#{semesterTO.getSubjects()}" varStatus="loop"
                var="subjects" id="subjectsId">
                <th>#{subjects.Name}</th>
            </c:forEach>
        </tr>
    </thead>
    <tbody>
        <c:forEach items="#{semesterTO.getSemesters()}" var="semester"
            varStatus="status1">
            <tr>
                <td><h:outputText value="#{semester.semesterId}" /></td>
            </tr>
        </c:forEach>
        <c:forEach items="#{semesterTO.subjectSemesterList()}" var="a"
            varStatus="status2">
            <tr>
                <td><h:selectBooleanCheckbox
                        value="#{semesterTO.enrolledSubjects[a]}" /></td>
            </tr>
        </c:forEach>
    </tbody>
</table>
user679526
  • 845
  • 4
  • 16
  • 39

1 Answers1

0

You can use datatables. Follow this tutorial https://www.mkyong.com/jsf2/jsf-2-datatable-example/

or you can google another one, there are plenty :)

A.D
  • 47
  • 1
  • 1
  • 11