-
Book Overview & Buying
-
Table Of Contents
Grails 1.1 Web Application Development
By :
The implementation we have for file upload works fine and is easy to understand, but it is also quite naive in terms of efficiency. The problem is that every time a user views the information about a file, all the binary data for the file will be loaded into the memory. By altering our domain model slightly, we can easily improve the performance. We will need a domain class to represent the data as a one-to-one relationship with the File object. We saw in Chapter 5 that relationships between domain objects are lazy by default. This means that, by extracting the data out into its own object, retrieving a list of files will not load the binary data of the file, unless we request it specifically.
Create a new domain class named FileData in the same package as the File domain class:
package app
class FileData {
private static final int TEN_MEG_IN_BYTES = 1024*1024*10
static belongsTo = [file:File]
byte[] data
static constraints = {
data( nullable: false, minSize: 1, maxSize...
Change the font size
Change margin width
Change background colour