我想访问 play.api.data.Field 中的对象。这是相关的类。
入口控制.java
@Entity
public class EntryControl extends Model {
@Id
public Long id;
public String comment;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entryControl")
public List<EntryControlItem> entryControlItemList;
public static Model.Finder<Long,EntryControl> find = new Model.Finder<Long,EntryControl>(Long.class, EntryControl.class);
}
EntryControlItem.java
@Entity
public class EntryControlItem extends Model{
@Id
public Long id;
@ManyToOne
@Constraints.Required
public Analysis analysis;
public Boolean passed;
public String comment;
@ManyToOne
@Constraints.Required
public EntryControl entryControl;
public static Model.Finder<Long,EntryControlItem> find = new Model.Finder<Long,EntryControlItem>(Long.class, EntryControlItem.class);
}
分析.java
@Entity
@JsonSerialize(using = AnalysisSerializer.class)
public class Analysis extends Model {
@Id
@Formats.NonEmpty
public Long id;
@Constraints.Required
public String name;
...
public static Model.Finder<Long,Analysis> find = new Model.Finder<Long,Analysis>(Long.class, Analysis.class);
}
现在我在模板中迭代包含一些 EntryControlItem 对象的 EntryControl.entryControlItemList。
表格.scal
@(entrycontrolForm: Form[entrycontrol.EntryControl], status: String)
@repeat(entrycontrolForm("entryControlItemList"), min = 0) { entryControlItem =>
@checkbox(entryControlItem("passed"),
'lable -> "Verbergen",
'class -> "checkbox",
'showTable -> true)
@entryControlItem("analysis").value // <-- the problem is here
}
我想访问对象分析的“名称”字段。当我运行这个模板时,我在屏幕上看到“models.analysis.Analysis@1”
@entryControlItem("analysis").value // prints models.analysis.Analysis@1
如何访问 Analysis.name 的字段?