A
A
Alena2017-01-18 12:53:13
Java
Alena, 2017-01-18 12:53:13

How to stop reading a list?

Hello,
please help, I can't figure out how to stop reading from List.

public String NumberOfRecords() {
        String n1 = tableCity.get(n2);
        n2++;     
        return n1;   
    }

tableCity - List, populated from the database.
You enter this data into a table. The table is dynamic.
<div id="list" >
            <f:view>
                <h:form>   
                    <p:dataTable var="directory" value="#{dataDB.tableCity}" style="margin-bottom:280px; font-size: 12px">
                     <!--  <p:ajax event="rowEdit" listener="#{dtEditView.onRowEdit}" update=":form:msgs" />
                        <p:ajax event="rowEditCancel" listener="#{dtEditView.onRowCancel}" update=":form:msgs" />
                        -->
                        <c:forEach items="#{dataDB.columns}" var="obj">
                            <p:column headerText="#{dataDB.NumberOfColumn()}" >  
                                     <h:outputText value="#{dataDB.NumberOfRecords()}" />
                            </p:column>
                        </c:forEach>
                    </p:dataTable>
                </h:form>
            </f:view>
        </div>
I understand with my brain that I need to put some kind of limiter or foreach, but I can’t think of which one.
Gives an error Index 304, Size:304 (in sheet 304 entries, by the way, if you display System.out.print(n1) - then all entries in the log are read and then an error)
Part of the log:

Severe: Error Rendering View[/directory.xhtml]
javax.el.ELException: /directory.xhtml @63,85 value="#{dataDB.NumberOfRecords()}": java.lang.IndexOutOfBoundsException: Index: 304, Size: 304
.......................
FATAL: JSF1073: javax.el.ELException caught during processing of RENDER_RESPONSE 6 : UIComponent-ClientId=, Message=/directory. xhtml @63,85 value="#{dataDB.NumberOfRecords()}": java.lang.IndexOutOfBoundsException: Index: 304, Size: 304
FATAL: /directory.xhtml @63,85 value="#{dataDB.NumberOfRecords( )}": java.lang.IndexOutOfBoundsException: Index: 304, Size: 304
javax.el.ELException: /directory.xhtml @63,85 value="#{dataDB.NumberOfRecords()}": java.lang.IndexOutOfBoundsException: Index: 304, Size: 304
....................

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question