How to avoid nested views

2013-09-19
2013-11-11
  • Jose Roman Bilbao

    I have three entities:

    • Entity company

      @OneToMany(mappedBy="company")
      private Collection<Farmer> farmers;

    • Entity farmer

      @ManyToOne(optional=true)
      private Company company;

      @OneToMany(mappedBy="farmer")
      private Collection<Farm> farms;

    • Entity farm

      @Required
      @ManyToOne
      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):

    Farmer
    |-- 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,

    Jose.

     
    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.

    http://openxava.wikispaces.com/view_en

     
    • 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...

      Greetings

       
  • 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 {
    
        @ManyToOne
        @ReferenceView("Simple")
        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

      Thanks!

       

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