Menu

OneToMany ListProperties Editor shows mappedBy properties, not ListProperties

2021-02-10
2024-08-07
  • Dusan Djuric

    Dusan Djuric - 2021-02-10

    I'm banging my head to screen for some time now having hard time to implement custom List editor for my Collection @ListProperties:

    module

    @OneToMany(mappedBy="master",...)
    @ListProperties(....
    @Editor(value="MyCustomList") 
    private Collection<Details> details;
    getter setter ...
    

    xava/editors.xml

    <editor name="NoCustomizationList" url="noCustomizationListEditor.jsp"></editor>
    

    myCustomList.jsp is exact copy of ListEditor.jsp

    When I specify @Editor(value="MyCustomList") module shows collection list tab for @OneToMany(mappedBy="master" data, not for private Collection details.

    I tried to name @View, @Tab, @View & @Tab in Details entity module and specify forViews and value syntax for @Editor but no correct result. Even if I specify @Editor("List") witch is pure standard List editor, I get data from master, not detail. If I don't specify @Editor it works fine and shows detail data specified in @ListProperties

     

    Last edit: Dusan Djuric 2021-02-10
  • Javier Paniza

    Javier Paniza - 2021-02-12

    Hi Dusan:

    myCustomList.jsp is exact copy of ListEditor.jsp

    That's the problem, listEditor.jsp is for list mode, not for collection. You should use collectionEditor.jsp, that yes, it calls to listEditor.jsp but before configures some things. Have a look at collectionEditor,jsp.


    Help others in this forum as I help you.

     
    • Dusan Djuric

      Dusan Djuric - 2021-02-12

      Great!

      My goal is to have simple Tab display, no customization, no filtering, no column sorting. Just column names and data.

      Can you give me a tip? I tried with copy of collectionEditor.jsp but have no clue where is the point where I can swap listEditor.jsp include with my own? Am I doing it right? Is there some other list editor (jsp) called by collectionEditor.jsp where I can disable custom, filter, column order icons and logic?

       

      Last edit: Dusan Djuric 2021-02-12
  • Dusan Djuric

    Dusan Djuric - 2021-02-12

    This is CSS technique I used at the end to have simple no customization, no filtering, no column sorting collection list presentation.

    /* removing customization and filters for specific module-subview-collection */
    #ox_<myApplicationName>_<ModulName>__customize_<subViewCollectionName>,
    #ox_<myApplicationName>_<ModulName>__list_filter_<subViewCollectionName>,
    #ox_<myApplicationName>_<ModulName>__show_filter_<subViewCollectionName>
    {
        display: none;
    }
    
    /* removing href for specific module-subview-collections tab */
    #ox_<myApplicationName>_<ModulName>__<subViewCollectionName> .ox-list-header div span a[href]
    {
        cursor: not-allowed;
        pointer-events: none;
        text-decoration: none;
    }
    
    /* removing sort icons for specific module-subview-collections tab */
    #ox_<myApplicationName>_<ModulName>__<subViewCollectionName> .ox-list-header div span a[href] i
    {
        display: none;
    }
    

    This will probably work fine until OX team decide to change something in jsp(s). Therefore, it would be much appreciated to give some methods, properties and annotations of @ListProperties, @Tabs and columns, something like

    Tab.setCustomizeAllowed(boolean)
    Tab.setFilteringAllowed(boolean)
    Tab.setSortableAllowed(boolean)

    or even more flexible
    Tab.Property.setCustomizeAllowed(boolean)
    Tab.Property.setFilteringAllowed(boolean)
    Tab.Property.setSortableAllowed(boolean)
    so we can have some fields customizable, filterable, sortable and others don't.

     
  • Javier Paniza

    Javier Paniza - 2021-02-15

    Hi Dusan:

    Look at this pending feature:
    https://openxava.org/XavaProjects/o/OpenXava/m/Issue?detail=536371b7f1ab4eef936dc7de140e8b67

    By now you can create a calculated collection from your persistent collection, something that simplified the UI a lot, thus:

    @OneToMany(mappedBy="master",...)
    @ListProperties(....
    @Editor(value="MyCustomList") 
    private Collection<Details> details;
    
    public Collection<Details> getSimpleDetails() {
            return getDetails();
    }
    

    Then you can put simpleDetails in your @View definition instead of details.


    Help others in this forum as I help you.

     
  • Dusan Djuric

    Dusan Djuric - 2021-02-15

    Pending feature is from 2016. If I may suggest so: @Simple shuld be @Options an should have few or more properties (customization=true/false, filter=true/fale, order=true/fale, resize=true/false ... ), I earlier mentioned adequate properties and methods.

    By now you can create a calculated collection from your persistent collection, something that simplified the UI a lot, thus:

    I tried calculated collection, which is by my opinion both quite scriptical and not very clear, and implicates that the citation in @View does not seem to be based on the Collection object name but on the name of the getter function. Pretty confusing I think. However, it does not suit me for several reasons:

    • @ListSubcontroller disapiers

    • Thows primitiv type error

    SEVERE: Null value was assigned to a property [class com.istratech.attendancerecord.model.TimeRecords.paidFlag] of primitive type setter of com.istratech.attendancerecord.model.TimeRecords.paidFlag
    org.hibernate.PropertyAccessException: Null value was assigned to a property [class com.istratech.attendancerecord.model.TimeRecords.paidFlag] of primitive type setter of com.istratech.attendancerecord.model.TimeRecords.paidFlag
    Caused by: java.lang.IllegalArgumentException: Can not set int field com.istratech.attendancerecord.model.TimeRecords.paidFlag to null value
    (I removed setters but get same exception anyway)

    • Thows
      org.openxava.controller.ModuleManager manageRegularException
      SEVERE: View.getCollectionTab() not allowed for @ManyToMany, @OrderColumn or calculated collections
      java.lang.IllegalStateException: View.getCollectionTab() not allowed for @ManyToMany, @OrderColumn or calculated collections

    • List header and all rows gets remove option, and rows get update options
      although seting are @ReadOnly @NoCreate @NoModify @RemoveAction("") @ RemoveSelectedAction("") @ViewAction("") @NewAction("") @AddAction("") @SaveAction("")

     

    Last edit: Dusan Djuric 2021-02-15
  • Javier Paniza

    Javier Paniza - 2021-02-17

    Hi Dusan:

    Pending feature is from 2016

    From 2016 to 2020 we have added 447 new features to OpenXava and fixed 435 bugs. You can verify it here:
    https://openxava.org/changelog/

    I don't in favor of increasing the amount of features added in each version, because new features are inmature, they fail, no matter you test all possible cases with all possible browser, in production they fail. I remember when we added @ElementCollection support or creation our own editor (to replace the HTML select) for the @DescriptionsList, in the first version they failed. And recently with the new upload editor. That is, a new version with a huge quantity of new feature would create a fragile product. That is, the current amount of new features by year is good for keeping a good quality level. I'm even thinking in increasing the amount of bug fixes and decreasing the amount of new features.

    On the other hand, the amount of nice-to-have ideas is huge, and in each version we have to leave out some of them, because more important features are implemented.

    That is, probably we'll implement @Simple some day, but you cannot expect that all the pending features will be implemented for the next version, even more, you can expect all the request feature would be implemented at all. Personally, I would like to have a @Simple annotation for collection, and also it would be useful to have a more granulated alternative as you suggest.

    in @View does not seem to be based on the Collection object name but on the name of the getter function

    The @View annotation is always based in the getter function, for all members, never in the attribute. OpenXava follow the JavaBean convention for property definition. Read my explanation about calculated properties:
    https://openxava.org/OpenXavaDoc/docs/basic-business-logic_en.html#Lesson%205:%20Basic%20business%20logic-Calculated%20properties

    @ListSubcontroller disapiers

    It could be a bug.

    Thows primitiv type error

    This is because you have mapped an int property to a column that have nulls in database. You should not to do that. Given that the calculated collection shows all records, without paging it fails, I suspect.

    List header and all rows gets remove option

    Yes, calculated collection still allows customization. You can remove customization, though that is a topic for a new thread.

    rows get update option

    Did you try @EditAction("")


    Help others in this forum as I help you.

     
    • Dusan Djuric

      Dusan Djuric - 2021-02-17

      Hi Javier

      From 2016 to 2020 we have added 447 new features to OpenXava and fixed 435 bugs. You can verify it here:

      I appreciate your framework and your development efforts very much, otherwise I would not have asked my company to buy XavaPro. I just mention that I must get some solution to problem and have not much time left with my project to deliver, so CSS it is for now.

      Furthermore, I consider your development progress, and support consistency and response the one of the most agile among even "famous" companies. So don't get me wrong, and please keep in mind that my English is not my native so sometimes I sound different from what I had in mind.

      When I wrote "List header and all rows gets remove option" I meant to option to delete selected rows of data, not customization column removal option. I didn't try @EditAction("") because I put @ReadOnly @NoCreate @NoModify and I thought that that is enough. Thx for pointing me out on that, and thank you for all other useful informations you provided.

      With regards.

       

      Last edit: Dusan Djuric 2021-02-19
  • Javier Paniza

    Javier Paniza - 2021-02-19

    Hi Dusan,

    Don't worry. I like the people that complains, because it improves OpenXava. In that case, for example, I just give more priority for this @Simple option for collection, plannig for 6.6. Surely it will not in 6.6, but perhaps in 6.7.

    I meant to option to delete selected rows of data

    Try @ReadOnly. Also you can use @ViewAction(""), if you dont want the row action for view a read only dialog with the detail. If it fails put here the source code for your collection definition and a screenshot of the result, so I understand better.


    Help others in this forum as I help you.

     
    • Dusan Djuric

      Dusan Djuric - 2021-02-19

      Hi Javier

      This is my example.

      @OneToMany(mappedBy="attendee", fetch=FetchType.LAZY)
      @ListProperties(""
      +"prevEventGroup," 
      +"prevEventSubgroup," 
      +"prevEventName," 
      +"grpPresencDurationhhmmss," 
      +"paidFactor," 
      +"subgrpPaidDurationhhmmss,"
      +"grpPaidDurationhhmmss"
              )
      @XOrderBy("prevEventGroup asc,prevEventSubgroup asc, prevEventName asc")
      @ReadOnly @NoCreate @NoModify 
      @ViewAction("") @RemoveAction("") @RemoveSelectedAction("") @EditAction("") @NewAction("") @AddAction("") @SaveAction("") 
      private Collection<TimeRecordsEvtGrpSum> timeRecordsEvtGrpSum;
      public  Collection<TimeRecordsEvtGrpSum> getTimeRecordsEvtGrpSum() {return timeRecordsEvtGrpSum;}
      public  void setTimeRecordsEvtGrpSum(Collection<TimeRecordsEvtGrpSum> timeRecordsEvtGrpSum) {this.timeRecordsEvtGrpSum = timeRecordsEvtGrpSum;}
      

      Capture1.jpg shows "normal" Collection
      Capture2.jpg shows same but calculated Collection

      It is the same collection but calculated version losses column and collection title translations, and shows (I don't know way) all columns, although only few are specified in @ListProperties

      In calculated version you can see (in read circles) Update and Delete icons, but in annotations is clearly specified @ReadOnly @NoModify @RemoveAction("") @RemoveSelectedAction("") @EditAction("") . Even Add and New are there although @NewAction("") @AddAction("") are specified. So calculated collection trick gives more headache than CSS.
      Only column sorting icons disappears, with is desirable in my particular case, but does not provide the flexibility like by CSS to keep sorting as an option.

       

      Last edit: Dusan Djuric 2021-02-19
  • Javier Paniza

    Javier Paniza - 2021-02-23

    Hi Dusan,

    I just tried this code:

    @ReadOnly
    public Collection<Carrier> getFellowCarriersCalculated() {
        return getFellowCarriers(); // We call to the persistent counterpart
    }
    

    To get the attached result.
    That is @ReadOnly works nicely for calculated collections. Remeber that you have to annotated the getter of the colletion and that a calculated collection only has the getter, it has not field and setter. If you don't find the problem, attach here the class code of the entity that contains the calculated collection configured to use it in the view. I'll have a look.


    Help others in this forum as I help you.

     
    • Dusan Djuric

      Dusan Djuric - 2021-02-23

      Hi Javier,

      I probably copied the wrong code, in the one I intended to put is
      public Collection <timerecordsevtgrpsum> getSimpleTimeRecordsEvtGrpSum () {return getTimeRecordsEvtGrpSum ();}</timerecordsevtgrpsum>

      but with setter procedure also.

      I'll try this variant for sure and get back to you with results.

       
  • Dusan Djuric

    Dusan Djuric - 2021-02-23

    Hi Javier

    I get exactly the same result like before (have a look at the picture). In addition, export PDF and Excel actions disappear. Also, @ListProperties is not consulted at all, but all the fields from the original collection class are displayed. It's clear to me why the labels weren't translated, but I don't understand why all the columns are displayed instead of just those in @ListProperties.

    I probably didn’t understand you well and I’m doing something fundamentally wrong.

    The attached code is long, but it is about "private Collection <timerecords> timeRecords", or "getTimeRecordsCalculated" and "timeRecordsCalculated" as stated in @View.</timerecords>

    I'm sorry to waste your precious time.

    Regards

     
  • Javier Paniza

    Javier Paniza - 2021-02-25

    Hi Dusan,

    In your code the property timeRecordsCalculated has no annotations at all. You should annotate the collection timeRecordsCalculated with @ReadOnly and @ListProperties. In this way:

    @ListProperties(""
        + "prevGatewayName,"
        + "prevEventTime,"
        + "prevEventName,"
        + "gatewayName,"
        + "eventTime,"
        + "eventName,"
        + "gNo,"
        + "prevEventGroup,"
        + "sgNo,"
        + "prevEventSubgroup,"
        + "grpPresencDuration,"
        + "paidFactor,"
        + "grpPaidDurationUnconsolidated,"
        + "subgrpPaidDuration,"
        + "grpPaidDuration"
    )
    @ReadOnly
    public  Collection<TimeRecords> getTimeRecordsCalculated() {return getTimeRecords();}
    

    Remember that a calculated property or a calculate collection is just a getter, without setter and without field. You have to annotate that getter.


    Help others in this forum as I help you.

     
    • Dusan Djuric

      Dusan Djuric - 2021-02-25

      Hi Javire
      I get it now. Thx!

       
  • Dusan Djuric

    Dusan Djuric - 2021-02-25

    Sorry, but I'm completely confused and still can get trough.

    this is my code

    @OneToMany(mappedBy="attendee", fetch=FetchType.LAZY)
    @ListProperties(""
            + "prevGatewayName,"
            + "prevEventTime,"
            + "prevEventName,"
            + "gatewayName,"
            + "eventTime,"
            + "eventName,"
            + "gNo,"
            + "prevEventGroup,"
            + "sgNo,"
            + "prevEventSubgroup,"
            + "grpPresencDuration,"
            + "paidFactor,"
            + "grpPaidDurationUnconsolidated,"
            + "subgrpPaidDuration,"
            + "grpPaidDuration"
                   )
    @XOrderBy("eventTime asc")
    @ViewAction("") @RemoveAction("") @RemoveSelectedAction("") @EditAction("") @NewAction("") @AddAction("") @SaveAction("") 
    @ReadOnly @NoCreate @NoModify  
    private Collection<TimeRecords> timeRecords;
    public  Collection<TimeRecords> getTimeRecords() {return timeRecords;}
    
    @OneToMany(mappedBy="attendee", fetch=FetchType.LAZY)
    @ListProperties(""
            + "prevGatewayName,"
            + "prevEventTime,"
            + "prevEventName,"
            + "gatewayName,"
            + "eventTime,"
            + "eventName,"
            + "gNo,"
            + "prevEventGroup,"
            + "sgNo,"
            + "prevEventSubgroup,"
            + "grpPresencDuration,"
            + "paidFactor,"
            + "grpPaidDurationUnconsolidated,"
            + "subgrpPaidDuration,"
            + "grpPaidDuration"
                   )
    @XOrderBy("eventTime asc")
    @ReadOnly  
    private Collection<TimeRecords> timeRecordsCalculated;
    public  Collection<TimeRecords> getTimeRecordsCalculated() {return getTimeRecords();}
    

    timeRecordsCalculated is defined in @View and this is what I get:

    Adding @ViewAction("") solves View (eye icon) but customization, filtering, sorting is still there.
    I give up and go back to CSS solution, sorry.

     

    Last edit: Dusan Djuric 2021-02-25
  • Javier Paniza

    Javier Paniza - 2021-03-02

    Hi Dusan:

    Calculated collections have no field. In the moment you use a field that is a persistent collection, your even use @OneToMany, calculated collections have no persistence annotations.

    Write it in this way:

    @ListProperties(""
            + "prevGatewayName,"
            + "prevEventTime,"
            + "prevEventName,"
            + "gatewayName,"
            + "eventTime,"
            + "eventName,"
            + "gNo,"
            + "prevEventGroup,"
            + "sgNo,"
            + "prevEventSubgroup,"
            + "grpPresencDuration,"
            + "paidFactor,"
            + "grpPaidDurationUnconsolidated,"
            + "subgrpPaidDuration,"
            + "grpPaidDuration"
                   )
    @XOrderBy("eventTime asc")
    @ReadOnly  
    public  Collection<TimeRecords> getTimeRecordsCalculated() {return getTimeRecords();}
    

    Note, without @OneToMany and without attribute.

    Read this explanation about collections where there is an example of a calculated collection:
    https://openxava.org/OpenXavaDoc/docs/model_en.html#Model-Collections

    Read also this explanation about calculated properties in general:
    https://openxava.org/OpenXavaDoc/docs/basic-business-logic_en.html#Lesson%205:%20Basic%20business%20logic-Calculated%20properties


    Help others in this forum as I help you.

     
  • Javier Paniza

    Javier Paniza - 2024-08-07

    Hi Dusan,

    Finally, we have added the annotation @SimpleList to OpenXava, to have a collection displayed without filtering, sorting, customization, paging, actions, etc. The code is already in the master and will be included in OpenXava 7.4, available in September 2024.

     
    👍
    1

Log in to post a comment.