Abdullah Shaikh wrote:
"If your groovy compile some information, do findList, getRelated ... , if
you deploy for a customer a screen that don't use all information, you
generate unnecessary work to your database."

But in groovy you will need to get only that data from database which will
be required for the FTL page

It's like if an existing FTL gets "xyz" data from database, using this
approach it will be like, groovy get "xyz" data from the database and
putting it inside the context, FTL will get this data from the context.
If you use closures then the calls will only occur when they are used...

Groovy:

context.userDetails = {
   def user =  dispatcher.runSync("getSpecialUser", [])
   if (user.entityName == "Person") return """
   <tr>
       <td>
           <span class="firstname">$user.firstName</span>
           <span class="lastname">$user.lastName</span>
            is definitely a person.
       </td>
   </tr>
""" else return """
   <tr>
       <td>
           <span class="notperson">User is not a person.</span>
       </td>
   </tr>
"""
}

FTL:

<table>
$userDetails.call()
</table>

This way the work of generating the user details is never done unless the FTL pulls them in. This approach is useful for all kinds of formatting chores.

Reply via email to