Skip to content
Advertisement

Link fires method multiple no. of times

The problem is that whenever I click the link Next page on Home.xhtml to goto getMoreStatusList Page, the function getMoreStatusList is called non-stop until it throws a index out of bound exception. I am even printing the value of index that I get from the session object statusindex and the string insidegetmorestatusList when inside the getMoreStatusList() method to the console ,I use the method results = results.subList(index,index+5); to create sublist but this line is getting called more than once and is throwing out of bound exception as the value of index gets incremented with each call.

1)Home.xhtml

JavaScript

2) Status Bean(this contains the getMoreStatusList function)

JavaScript

3) getMoreStatusList.xhtml

JavaScript

3) Stacktrace(I have cut it short because the limit is 30000)

JavaScript

Advertisement

Answer

You should use <ui:repeat> (with xmlns:ui="http://java.sun.com/jsf/facelets") instead of <c:forEach>

foEach is a tag handler, repeat is a component. You can read more about the difference between the two on this blog

JavaScript

and

JavaScript

to get rid of IndexOutOfBoudsException use the following in getMoreStatusList:

JavaScript

and in getStatusList:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement