<表:列>引用实体属性的 Roo 标签表:列>
我在 Roo 项目中有两个班级(学生、班级)及其脚手架视图。
学生和班级有 1:1 的关系
在学生的 list.jspx 中,我想显示班级属性的列。
我不知道赋予 table:column-tag 的正确属性。 下面的示例给出了错误:
SpelEvaluationException:EL1027Epos 4):不支持对“com.pupil”类型进行索引
<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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以简单地通过在
ApplicationServiceFactoryBean.java
中实现Teacher
实体的转换器来实现此目的,而不用搞乱 jspx 文件。请参阅下面的转换方法示例。
默认情况下,Roo 生成这些转换器,并将它们存储在
ApplicationConversionServiceFactoryBean_Roo_ConversionService.aj
文件中。您可以将这个aspectJ文件中
Teacher
实体的相关方法推入重构ApplicationServiceFactoryBean.java
文件,然后实现您自己的转换,该转换将用于在应用程序中显示Teacher
名称,如上例所示。干杯,祝 Roo 一切顺利!
Instead of messing around with the jspx files, you can simply do this by implementing a converter for the
Teacher
entity within theApplicationServiceFactoryBean.java
.See the below conversion method for an example.
By default, Roo generates these converters and they are stored within the
ApplicationConversionServiceFactoryBean_Roo_ConversionService.aj
file.You can push in refactor the related method for the
Teacher
entity from this aspectJ file into theApplicationServiceFactoryBean.java
file and then implement your own conversion which will be used to show theTeacher
name across the application as in the above example.Cheers and all the best with Roo!
我就是这样做的,不是为了列出,而是为了在查看学生实体时显示老师的姓名:
在 show.jspx 文件中添加如下内容:
>
(或者,您可以使用自己的参数创建一个新的 tagx 文件)
希望它有所帮助。
拉杜
This is how I did it, not for listing, but rather for showing the name of the teacher when you view the pupil entity:
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