How to avoid nested views

  • Jose Roman Bilbao

    I have three entities:

    • Entity company

      private Collection<Farmer> farmers;

    • Entity farmer

      private Company company;

      private Collection<Farm> farms;

    • Entity farm

      private Farmer farmer;

    This generates a too complex view when accessing module agricultor with Company and Farms data boxes being nested in the same view. How can I avoid that. For example, when I am accessing the module Company, I want its farmers to appear just down when clicking on "Both", which is right. But when I click on Farmer's module and select Both, Nested appear (look at the attached file also):

    |-- Company
    | |-- Company Farmers
    |-- Farms

    Farmer, Company and Farms would be ok in this wiew, but not Company Farmers wich is way to much information for a single Farmer to be shown. How can I control this?. I have read and followed the book but with no luck. For example, on the Invoicing app, relationships are not staablised on both sides as I do (for example, farm is related to farmer and farmer to farm), is this wrong on my part?

    Thanks in advance,


    Last edit: Jose Roman Bilbao 2013-09-19
  • Giuseppe

    Giuseppe - 2013-09-19

    You can create a named view and refer to it from parent classes.

    • Jose Roman Bilbao

      Thanks but, Is it correct or even necessary to stablish the relationship connection on both Entities?. As said, the Invoicing example does not do it and I don't fully understand when should I do it and when not...


  • Javier Paniza

    Javier Paniza - 2013-09-23

    Hola José,

    If you want not to show Company when accesing Farmer, just define a view for Farmer with no company, in this way:

    @View(members="name, otherDate; farms") // but not company
    public class Farmer {

    On the other hand if you want to show company data, but not all company data from Farmer, user @ReferenceView:

    // You can even use the default view
    public class Farmer {
        private Company company;
    @View(name="Simple", member = "name, otherDate") // but not farmers
    public class Company {

    Ayuda a otros en este foro como yo te ayudo a ti.
    ¿Necesitas más ayuda? Usa el soporte profesional de OpenXava

    • Jose Roman Bilbao



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks