You will not
want to call the database that many times, so you will need to include some logic to
cache the result returned by this method, and update it only when necessary. But,
again, we are looking at the principles here, so let's keep everything simple.
The prepare method does the main job of requesting the database and obtaining
a subset of entities from it to be displayed by the current page of the table. The
subset is limited by the first two parameters??”indexFrom and indexTo, which are
the indexes of the first and the last entities to be returned. They might be used in a
SELECT statement which would command the database to select all the entities and
then limit the selection in one way or another, depending on the SQL dialect.
The third parameter of this method, propertyModel, is used to define the column by
which the result should be sorted. Again, we could use this parameter in a SELECT
statement, but here we are simply outputting the name of the property to see what
the Grid has passed to the method.
Finally, the ascending parameter could be used to define the order in which the
results should be sorted when speaking to the database, but we are just outputting
its value.
Pages:
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186