play.api.data.Field にあるオブジェクトにアクセスしたいと思います。これは関連するクラスです。
EntryControl.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 をテンプレートで反復処理しています。
フォーム.スケール
@(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 のフィールドにアクセスするにはどうすればよいですか?