« Return to Thread: ManyToMany Custom Look

ManyToMany Custom Look

by ghachey :: Rate this Message:

Reply to Author | View in Thread

Hi,

I'm very new to trails, and tapestry and hibernate too by that matter.  I'm evaluating trails but I have been blocked on this problem for a few days now.

I have a Society entity and a Person entity.  They are linked with a ManyToMany relationship like follows in Society.java:

@PropertyDescriptor(index = 14, searchable = false, summary = false)
@ManyToMany(
    targetEntity = vu.gov.departmentcooperative.Person.class,
    cascade = {CascadeType.PERSIST, CascadeType.MERGE}
)
@JoinTable(
    name = "society_person",
    joinColumns = @JoinColumn(name = "society_id"),
    inverseJoinColumns = @JoinColumn(name = "person_id")
)
public List<Person> getMembers() {
        return members;
}

public void setMembers(List<Person> newMembers) {
        this.members = newMembers;
}

The default look for this type of field when editing a Society is to use a palette component.  I changed this to include a TableObject of members (Person.java) belonging to that particular society like follows:

        <form jwcid="@trails:ObjectForm" model="ognl:model">
          <!-- Custom look (component) for members attribute -->
          <div id="members">
            <div id="left" style="float:left;" jwcid="members@Block">
              <li><label class="desc">Members</label>
                <table class="table contribTable" jwcid="@trails:ObjectTable"
                       rowsClass="ognl:beans.evenOdd.next"
                       instances="ognl:model.members"
classDescriptor="ognl:page.descriptorService.getClassDescriptor(classDescriptor.getPropertyDescriptor('members').elementType)"/>
              </li>
            </div>
            <div id="right" jwcid="@If" condition="ognl:classDescriptor.allowSave">
              <li>
                a class="newlink" href="#" jwcid="@trails:NewLink" type="ognl:@vu.gov.departmentcooperative.Person@class">Add a New Member
              </li>
            </div>
          </div>
        </form>

This obviously adds a new Person in the database but not specific to the Society I had opened for edit (or any Society at all).  In other words, it does not update the ManyToMany's JoinTable (society_person).

image for clarity.



Can someone help me out?

--
Ghislain Hachey

 « Return to Thread: ManyToMany Custom Look