Announcement Announcement Module
No announcement yet.
ONE_TO_MANY issue Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • ONE_TO_MANY issue

    As decsribed here when I use ONE_TO_MANY cardinality on "ONE side" web page is shown message explaining that this relationship is managed from the many-side.
    I think sometimes this isn't good practise. Consider two classes. Person and his Address. Person may have multiple addresses (e.g. mailing, permanent). So I will use this script:
    entity --class ~.domain.Address
    field string --fieldName city
    field string --fieldName street
    field string --fieldName postCode
    entity --class ~.domain.Person
    field string --fieldName firstName
    field string --fieldName lastName
    field set --fieldName adresses --type ~.domain.Address --cardinality ONE_TO_MANY
    But there is no possibility to set address of person now. I don't understad why I can't set it on Person side if I want so. I consider it a bug.

    There is one possible solution. In WEB-INF/views/people/create.jspx change
    <field:simple field="adresses" id="c_cz_roo_example_domain_Person_adresses" messageCode="entity_reference_not_managed" 
    messageCodeAttribute="Address" z="XruKHKVBfeytK98vQdcpQFkSoms="/>
    <field:select field="adresses" id="c_cz_roo_example_domain_Person_adresses" itemValue="id" 
    items="${addresses}" multiple="true" path="adresses" z="XruKHKVBfeytK98vQdcpQFkSoms="/>
    You have to do same thing in update.jspx and then it works.

    My question is why I can't do that (set attribute value at ONE side) by default? Thank you
    Last edited by Mamut; Feb 27th, 2011, 03:28 PM.

  • #2
    This is also bugging me, however your solution is still not ideal.

    when you add the customer details and then click on the add address icon the customer details are forgotten, so this is still not a true solution.

    What Roo should offer is the ability to add the one to many relationship within the same form, in this case have both customer and address data within a single form.