My question is if I have 1000 items then 1000 * 2 outputText components will be created in memory. How do we avoid creating too many components in the memory? Is it possible? How ui:repeat tag will be helpful in this situation?
Actually, there'd be 1000 model row elements consisting of 2000 text items and 1000 boolean items. The rendering would be controlled by a property returned by the isRendered in the model row class. Technically, any or all of the properties (text and boolean) might not be distinct depending on how you implement the model row, but I'm going for the brute-force case.
The datatable model is not the database model, so having 1000 items in it isn't really a good idea, since that means you'll be returning 1000 rows to the user's web browser on a single page request. That means time, bandwidth, and a strong possibility of overloading the user's eyeballs. I rarely top 50 rows/page myself.
Just to elaborate, the datatable model is not the database model, but it can be a window into the database model. This is possible, since elements in a Java collection are not copied by value, but simply references. Thus a data item in a database model collection can be referred to by other collections (such as the datatable model), but only one copy of the actual data would exist.
Science is the process of replacing what we "know" with what is TRUE. Politics, alas, often prefers to be the opposite.
I was going through the above link and find the following code and its explanation ->
In this case both the input and the output components are created.
The rendered is evaluated by the renderer during the rendering phase while the data table is iterating over each of its rows.
So in the above example, If my collections (bean.rows) has 10 items then 10 input and 10 output components will be created or only 2 components will be created.
If it creates 20 components in memory, when it is garbage collected. If I have too many components (checkbox, outputText, commandLink, commandButton - for each item) inside the datatable then it will affect the performance.
A day job? In an office? My worst nightmare! Comfort me tiny ad!