Hello i really need help with a Cforms binding which i can't get to work. I have two classes (User, Right) which have an m:n relation.
public class User implements Serializable {
private int id;
private String nick;
private String firstname;
private String lastname;
private String email;
private String pass;
private Collection rights = new ArrayList();
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
...
public Collection getRights() {
return this.rights;
}
public void setRights(Collection rights) {
this.rights = rights;
}
public void addRight(Right right) {
right.addUser(this);
this.rights.add(right);
}
}
public class Right implements Serializable {
private int id;
private String name;
private Collection users = new ArrayList();
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public Collection getUsers() {
return this.users;
}
public void setUsers(Collection users) {
this.users = users;
}
public void addUser(User user) {
this.users.add(user);
}
}
Now i have the following binding:
<fb:context
xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" path="/"
>
<fb:value id="id" path="id" direction="load"/>
<fb:value id="nick" path="nick" />
...
<fb:value id="confirmpass" path="pass" direction="load" />
<fb:repeater id="rights" parent-path="." row-path="rights">
<fb:identity>
<fb:value id="id" path="@id"/>
</fb:identity>
<fb:on-bind>
<!-- executed on updates AND right after the insert -->
<fb:value id="id" path="id" />
<fb:value id="name" path="name" />
</fb:on-bind>
<fb:on-delete-row>
<fb:delete-node />
</fb:on-delete-row>
<fb:on-insert-row>
<fb:insert-bean classname="papillon.Right" addmethod="addRight"/>
</fb:on-insert-row>
</fb:repeater>
</fb:context>
Inserting new Rights works fine, hte problem is that when i change a
right the old value is deleted from the Rights Table instead of only
deleting the entry in the reference table.
Can anyone of you help me how out on how an m:n relationship should be
binded?
I wrote a flowscript to test if my classes are ok and this is working
fine:
user = new Packages.papillon.User();
user.setId(15);
user = dao.retrieve(user);
firstname = user.getFirstName();
right = new Packages.papillon.Right();
right.setId(64);
rights = new Packages.java.util.ArrayList();
rights.add(right);
user.setRights(rights);
dao.update(user);
In my cforms i use the following flowscript:
var bean = new Packages.papillon.User();
id = 15;
bean.setId (id);
bean = dao.retrieve (bean);
form.load(bean);
form.showForm("form-display-pipeline-newuser",data);
form.save(bean);
dao.update (bean);
Christoph
pgpoQUBW2tyKF.pgp
Description: PGP signature
