20 December 2011

How to solve problem with "execution error occured in template {module:crud}/app/views/tags/crud/table.html. Exception raised was NullPointerException : Cannot get property 'type' on null object."

Play framework said that it's awesome ,because they error messages are meaningful. Yeah.Right.
Acctually, they are quite often ... but in this case ... not.

Error:

"Execution error occured in template {module:crud}/app/views/tags/crud/table.html. Exception raised was NullPointerException : Cannot get property 'type' on null object."


In {module:crud}/app/views/tags/crud/table.html (around line 54)


50:
                 %{ } else { }%

51:
                     %{ if(i == 0) { }%

52:
                         <a href="@{show(object._key())}">${object[field]?.toString()?.escape()?.raw() ?: '(no value)'}</a>

53:
                     %{ } else { }%

54:
                         %{ if(_caller.type.getField(field).type == 'file') { }%

55:
                             %{ if(object[field]) { }%

56:
                                 <a class="currentAttachment" href="@{attachment(object.id, field)}">${object[field].filename} (${object[field].get().size().formatSize()})</a>

57:
                              %{ } else { }%

58:
                                 

59:
                              %{ } }%

60:
                         %{ } else { }%


What does mean in plain English:
If you see this odd error
means that you screwed up something during declere something in crud.table in your view:

Example:
in your awesome view file list.html:

#{crud.table fields:['challenge,'image','openDate','closeDate']}

so if in your model variable ... for example  'challenge'  doesn't exist (because you misspell or forgot to create ) ,then you will see above "meaningful" message.