0

I am using <p:datatable> in UI to display the records using jsf. I am trying to add rows to the data table on click of Add button. On click of Add button, I am updating the list in the backing bean which in turn updates the datatable in UI with an extra row added. Now the issue is, the more I add rows to the data table, the more it becomes slow. Any solution for the same will be really appreciated.

Below is my sample code - 
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="#{dir}/template.xhtml" xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui">
  <p:dataTable id="employeeTable" var="emp" value="#{bbean.employeeList}"
    scrollable="true" scrollHeight="260" rowIndexVar="row">
    <ui:include src="column1.xhtml" />
    <ui:include src="column2.xhtml" />
    <ui:include src="column3.xhtml" />
    <ui:include src="column4.xhtml" />
    <ui:include src="column5.xhtml" />
    <ui:include src="column6.xhtml" />
    <ui:include src="column7.xhtml" />
    <ui:include src="column8.xhtml" />
    <ui:include src="column9.xhtml" />
    <ui:include src="column10.xhtml" />
    <ui:include src="column11.xhtml" />
    <ui:include src="column12.xhtml" />
    <ui:include src="column13.xhtml" />
    <ui:include src="column14.xhtml" />
    <ui:include src="column15.xhtml" />
  </p:dataTable>
  <p:commandButton id="addButton" value="Add" process="@this"
    actionListener="#{bbean.addEmployee}" oncomplete="DCVS.fn.focusOnTable('employeeTable')" />
</ui:composition> 
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
  • 1
    Don't update the table, but use https://www.primefaces.org/showcase/ui/data/datatable/addRow.xhtml – Jasper de Vries Mar 25 '21 at 14:16
  • Hi Jasper. Thanks for the reply. I am also doing the same in my code where I am updating the datatable list on add row. What I was looking for is if we can add rows to datatable in UI without dealing with back end or backing bean. Once the User add rows in UI and enters all the values for all the rows, all the data can be sent to back end for save in database in one go later. Please suggest. – aravind pratap Mar 26 '21 at 05:52
  • Please provide a [mcve] – Jasper de Vries Mar 26 '21 at 06:59
  • Hi Jasper, as I mentioned my concept is almost same as mentioned in the link https://www.primefaces.org/showcase/ui/data/datatable/addRow.xhtml provided by you. So as per the article share by you, what I want is when you click on 'Add new row' button, no backend call will be made and a row will get added to the table with empty cells where User can entry anything. Similarly, User can enter any number of rows on click of 'Add new row' button without hitting the backend or backing bean. – aravind pratap Mar 26 '21 at 09:58
  • Any help from anyone? – aravind pratap Mar 30 '21 at 06:14
  • If the backend code is the bottle neck, share it. See [mcve]. – Jasper de Vries Mar 30 '21 at 06:30

0 Answers0