yep this will indeed require "model trickery" which is not really that tricky.

public class PersonPropertyModel extends AbstractModel {
   private final IModel person;
   private final IModel type;

   //imagine a constructor here//

   Object getObject(Component c) {
          Person p=person.getObject(c);
          PropertyType t=type.getObject(c);
          return p.getPropertyOfType(t);
   }

   void setObject(Component c, Object o) {
          Person p=person.getObject(c);
          PropertyType t=type.getObject(c);
          p.setPropertyOfType(t, (PersonProperty)o);
  }

  ondetach() { person.detach(); type.detach(); }
}

so this is just a simple wrapper to a "map" that can insert new values. the trick is that the model knows the person and the type which are the two extra pieces of info you need to know except for the property itself. notice i made person and type models because i dont know how big they are and if you want to keep them in session.

-Igor

 

On 8/4/06, Mats Norén <[EMAIL PROTECTED]> wrote:
Hi,
I've got a form problem that I don't really now how to handle.

I've got three entities Person, PersonProperty and PropertyType.

A Person has a Set<PersonProperty>
A PersonProperty has a reference to a Person, a PropertyType and
contains a value.

What I would like to do is to edit a users dynamic properties by
showing them all on screen.
In a previous email to the list there was an example of a
Master-Detail form which seemed to be a good start. Code below:

ListView dynamicProperties = new ListView("propertiesAsList") {

                protected void populateItem(ListItem item) {


                    TextField valueField = new TextField("value");
                    valueField.setOutputMarkupId(true);
                    FormComponentFeedbackBorder feedbackBorder = new
FormComponentFeedbackBorder("feedback");
                    feedbackBorder.setRenderBodyOnly (true);
                    feedbackBorder.add(valueField);

                    item.add(feedbackBorder);

                    Label label = new Label("propertyType.name");
                     label.add(new AttributeModifier("for", true, new
Model(item.getId())));
                    item.add(label);
                }

                protected IModel getListItemModel(IModel
listViewModel, int index) {
                    return new
CompoundPropertyModel(super.getListItemModel(listViewModel, index));

                }


            }.setReuseItems(true);

This works great for editing the values of the dynamic properties a
user has already set, but what I would like to do is to iterate all
the possible ones, ie the PropertyType:s and get the values from the
PersonProperty if one exist or create one if it doesn't.
I think I need some model-trickery to achieve this but I can't really see it.

Any help would be appreciated!

//Mats

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to