Search code examples
spring-mvcspring-rootaglib

<table:column> Roo-tag for property of referenced entity


I've got a two classes (pupil, class) in a Roo-project and their scaffolded views.

pupil and class have a 1:1 relationship

In the list.jspx of pupil I'd like to display a column for a property of class.

I don't know the correct attributes to give to the table:column-tag. This following example gives the error:

SpelEvaluationException: EL1027Epos 4): Indexing into type 'com.pupil' is not supported

<table:table data="${pupil}" duplicate="true" id="l_com_pupil" path="/admin/pupil" z="user-managed">
   <table:column id="c_com_pupil_pupilName" property="pupilName" z="user-managed"/>
   <!-- I'd like to display the attribute teacher_name of the class 'class' here but it doesn't work -->
   <table:column id="c_com_pupil_class_teacherName" property="teacherName"  z="user-managed"/>
</table:table>

Solution

  • This is how I did it, not for listing, but rather for showing the name of the teacher when you view the pupil entity:

    • Edit the controller and specifically the method show (in the java file, not in the aj file, of course).
    • Add an attribute to your UI Model, for instance "teacherName" (use Model.addAttribute), where you populate the teacherName with the desired name.
    • Add in the show.jspx file something like:

      <div><label for="_pupilTeacher">Teacher Name:</label><div class="box">${teacherName}</div></div><br/>

    (alternatively, you could create a new tagx file with your own parameters)

    Hope it helped.

    Radu