Question

I would like to access an object which is in a play.api.data.Field. This are the related classes.

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);
}

Analysis.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);

}

Now I'm iterating in the template the EntryControl.entryControlItemList which contains some EntryControlItem objects.

form.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 
}

I would like to access to the field "name" of the object Analysis. When I run this template I see on the screen "models.analysis.Analysis@1"

@entryControlItem("analysis").value // prints models.analysis.Analysis@1

How can I access the field of Analysis.name?

Was it helpful?

Solution

Ok .. it was to simple :-). Next day, next try. I added the attribute to the object "analysis.name" and that was the solution. It can be handled such like the access of the object.

@entryControlItem("analysis.name").value
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top