Re: Mapping an association with Models

2009-11-10 Thread Xavier López
Hi,

Sorry, posted the previous one by error, this is what's missing in the code:


class APanel extends Panel(){
private List selectedBs;
public APanel(){
A a = getA();
List choices = getBChoices();
cbmc = new CheckBoxMultipleChoice("id", choices);
cbmc.setModel(new PropertyModel(this, selectedBs));
Form f = new Form("form"){
onSubmit(){
  List abs = a.getAB();
  abs.removeAll();
  for (B b : selectedBs){
 AB ab = new AB(a, b);
 abs.add(ab);
  }
  // a contains properly initialized ab elements
}
}
f.add(cbmc);
}

Question is, does 'selectedBs' get serialized in pageMaps ? If so, I suppose
it would be better to store only selectedB's id's...

Thanks, and sorry again for the double-posting inconvenience !
Xavier


Mapping an association with Models

2009-11-10 Thread Xavier López
Hi,

I'm wondering if I'm doing things straight regarding this subject.

I have an Entity A with PK properties a1, a2. There is another entity B with
PK properties b1, b2. Between them there is an association class AB (with PK
a1, a2, b1, b2). Let's suppose I have a Form for editing A objects, in which
the user can choose many B values by means of a CheckBoxMultipleChoice cbmc,
with model object and choice list of type List.
In the form's submit method, I create as many as necessary AB objects,
combining selected B's id's with current A's id.

class APanel extends Panel(){

private List selectedBs;

public APanel(){

}