Page 1 of 1

Display ManyToOne in listGrid

Posted: Mon Dec 17, 2012 10:42 am
by renob
Hi guys,

Is there a mean to display a field annoted with @ManyToOne (and @AdminPresentationToOneLookup) in a listGrid ?

Thanks

Re: Display ManyToOne in listGrid

Posted: Fri Dec 21, 2012 5:16 pm
by phillipuniverse
You can't display that field specifically, but you could display fields from the entity that the @ManyToOne relates to.

For instance, if you have something like this where ClassA is displayed in some list grid:

Code: Select all

@Entity
public class ClassA 
{

    @ManyToOne(targetEntity=ClassB.class)
    @AdminPresentationToOneLookup()
    protected ClassB relation;

}

@
Entity
public class ClassB 
{
    @AdminPresentation(friendlyName="Class B Property")
    public String someProperty;
}


You can annotate ClassA with some @AdminPresentationOverrides to enable showing some of ClassB fields:

Code: Select all

@Entity
@AdminPresentationOverrides({
    @AdminPresentationOverride(name="relation.someProperty", value=@AdminPresentation(friendlyName="Class B Property"))
})
public class ClassA {

    @ManyToOne(targetEntity=ClassB.class)
    @AdminPresentationToOneLookup()
    protected ClassB relation;

}