Q:

Customizing CRUD list.html in PlayFramework

Hello 
I'm trying to customize the list.html view for the CRUD section of a play application.
My model is like this
I have an object with a relation to an other object like so:
@Entity
public class MyObjectA extends Model {

    @Required
    public String myObjectAName;

    ...

    @Required
    @ManyToOne
    public MyObjectB myObjectB;
}

Now in the list.html that I overwride I have this
<div id="crudListTable">
    #{crud.table fields:['myObjectB', 'myObjectAName'] /}
</div>

Now doing this code will display something like this when calling the following url http://myplayapp/admin/myObjectAs in a browser
myObjectB __ myObjectAName
MyObjectB[1] __ Hey this a name for myObjectAName
MyObjectB[2] __ Hey this is another name for myObjectAName
Note the use of the Object name and the object id in [] for my MyObjectB.
So to display the myObjectBName property of MyObjectB in the list above, I try this:
<div id="crudListTable">
    #{crud.table fields:['myObjectB.myObjectBName', 'myObjectAName'] /}
</div>

But then I get this error

Execution error occured in template {module:crud}/app/views/tags/crud/table.html. >Exception raised was MissingPropertyException : No such property: myObjectB.myObjectBName >for class: models.MyObjectA. 

Of course MyObjectB has a public property myObjectBName 
So what am I doing wrong here?

A:

It's not working, because The fields parameter just takes a list of field names of the class to display (here MyObjectA) and "myObjectB.myObjectBName" isn't the name of a field in MyObjectA.
There are two ways to do this:
The simple solution is to override the toString() method of MyObjectB. This has the disadvantage, that the same string is used everywere a MyObjectB is displayed, and that may be not what you want.
Example:
public class MyObjectB extends Model {

  // ...

  @Override
  public String toString(() {
    return this.myObjectBName;
  }

}

The list specifc solution is to use the crud.custom tag. 
Example:
#{crud.table fields:['myObjectB', 'myObjectAName']}
   #{crud.custom 'myObjectB'}
       ${object.myObjectB.myObjectBName}
   #{/crud.custom}
#{/crud.table}

