0

I have a datatable like this:

<p:dataTable id="datatableid" value="#{manageBean.employeeList}" var="employeeObj" >
                        <p:column  style="width:10%;font-weight:bold">
                            <h:outputText value="#{employeeObj.firstName}-#{employeeObj.orgEmployeeId}"/>
                        </p:column>

                        <p:columns value="#{manageBean.fetchDataList(employeeObj)}"  var="dataObj">
                            <h:outputText value="#{dataObj.status}"/>
                        </p:columns>

                    </p:dataTable>

My bean is:

public List<Attendance> fetchDataList(Employee empObj)
        {
            System.out.println("**** Inside fectch attendance data **** "+empObj.getName());
            List<Attendance> attendanceList = new ArrayList<Attendance>();
            return attendanceList;
        }

While running, in syso i am getting null pointer exception because empObj is giving null.

How can i get exact value of empObj object?

What is the correct way to pass datatable variable(var) as argument into fetchDataList method which i have used as value in columns?

Developer
  • 157
  • 2
  • 18
  • I don't tested before to suggest, but try alter `value="#{manageBean.fetchDataList(employeeObj)}"` to `value="#{manageBean.fetchDataList(#{employeeObj})}"`; if doesn't works, alter `Employee empObj` to `Object empObj`. – BrTkCa Aug 25 '15 at 13:27
  • You try to use the `columns` tag in a wrong way. See the PrimeFaces showcase on how to use it. – Kukeltje Aug 25 '15 at 15:06
  • There's a major conceptual mistake here. A table cannot have different columns per row. The columns are to be defined on a per table basis. – BalusC Aug 25 '15 at 19:06

1 Answers1

0

Thanks for the comments guys. Myself solved the issue.

I created a new list for columns tag and created MAP inside Employee pojo and using that MAP, passed the key and got value.

<p:dataTable id="datatableid" value="#{manageBean.employeeList}" var="employeeObj" >
                        <p:column  style="width:10%;font-weight:bold">
                            <h:outputText value="#{employeeObj.firstName}-#{employeeObj.orgEmployeeId}"/>
                        </p:column>

                        <p:columns value="#{manageBean.newList}"  var="dataObj">
                            <h:outputText value="#{employeeObj.getMap().get(dataObj.status)}"/>
                        </p:columns>

                    </p:dataTable>
Developer
  • 157
  • 2
  • 18