Re: [Wicket-user] Form-question

2006-08-15 Thread Gwyn Evans
Sorry, just speed reading, saw the setOutputMarkupId() call which made
me think you might be doing Ajax...

As for your real question, I don't know.  I'm probably wrong, as it's
been a while since I looked into anything complex with models, but
  new CompoundPropertyModel(
new PersonPropertyModel(EditTeamPersonPanel.this.getModel()
seems to have an extra layer beyond what I'd expect?

If it's not that, then I'd be looking to see if it would be looking
for something like setObject(Component c, String s) rather than
setObject(Component c, Object o)?

/Gwyn


On 14/08/06, Mats Norén [EMAIL PROTECTED] wrote:
 Not really, I'm not using any Ajax-stuff or anything like that.
 How do you mean?

 /Mats


 On 8/14/06, Gwyn Evans [EMAIL PROTECTED] wrote:
  Does this thread apply?
  (http://www.nabble.com/ajax-failed-to-update-a-component-%28wicket-1.2%29-tf1844050.html#a5033398)
  /Gwyn
 
  On 13/08/06, Mats Norén [EMAIL PROTECTED] wrote:
   What I want the following code to do is to iterate all propertyTypes
   and create or lookup the appropriate property on my Person-object and
   create a TextField for each one.
  
   I've defined a model for the propertyTypes and a model for a
   TeamPerson-object which contains my Person.
  
   Everything works fine except that the setObject(Component c, Object o)
   in  PersonPropertyModel is never called.
   On screen the form renders and look fine but nothing gets written back.
  
   Would appreciate another pair of eyes on this.
  
  
   IModel propertyTypes = new LoadableDetachableModel() {
   protected Object load() {
   return userService.allPropertyTypes();
   }
   };
  
   ListView dynamicProperties = new
   ListView(dynamicProperties, propertyTypes) {
  
   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(valueField.getId(;
   item.add(label);
  
   }
  
   protected IModel getListItemModel(IModel
   listViewModel, int index) {
   PropertyType pt = (PropertyType)
   super.getListItemModel(listViewModel, index).getObject(null);
   return new CompoundPropertyModel(new
   PersonPropertyModel(EditTeamPersonPanel.this.getModel(), pt));
   }
  
   }.setReuseItems(true);
  
  
  
   public class PersonPropertyModel extends AbstractModel {
  
   private final IModel teamPerson;
   private final PropertyType propertyType;
  
   public PersonPropertyModel(IModel teamPersonModel,
   PropertyType propertyType) {
   this.teamPerson = teamPersonModel;
   this.propertyType = propertyType;
   }
  
   public Object getObject(Component c) {
   logger.info(Calling getObject for component:  + c.getId());
   TeamPerson tp = (TeamPerson) teamPerson.getObject(c);
   Person person = tp.getPerson();
   PersonProperty pp = person.getPropertyOfType(propertyType);
   if (pp == null) {
   logger.info(Adding new property);
   pp = new PersonProperty();
   pp.setPerson(person);
   pp.setPropertyType(propertyType);
   }
   return pp;
   }
  
   public void setObject(Component c, Object o) {
   TeamPerson tp = (TeamPerson) teamPerson.getObject(c);
   Person person = tp.getPerson();
   logger.info(Calling setObject for property:  +
   ((PersonProperty) o).getPropertyType().getName());
   person.setPropertyOfType((PersonProperty) o);
   }
  
  
   public void detach() {
   super.detach();
   teamPerson.detach();
   }
   }
  
   /Mats
  
   -
   Using Tomcat but need to do more? Need to support web services, security?
   Get stuff done quickly with pre-integrated technology to make your job 
   easier
   Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
   http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
   ___
   Wicket-user mailing list
   Wicket-user@lists.sourceforge.net
   https://lists.sourceforge.net/lists/listinfo/wicket-user
  
 
 
  --
  Download 

Re: [Wicket-user] Form-question

2006-08-14 Thread Gwyn Evans
Does this thread apply?
(http://www.nabble.com/ajax-failed-to-update-a-component-%28wicket-1.2%29-tf1844050.html#a5033398)
/Gwyn

On 13/08/06, Mats Norén [EMAIL PROTECTED] wrote:
 What I want the following code to do is to iterate all propertyTypes
 and create or lookup the appropriate property on my Person-object and
 create a TextField for each one.

 I've defined a model for the propertyTypes and a model for a
 TeamPerson-object which contains my Person.

 Everything works fine except that the setObject(Component c, Object o)
 in  PersonPropertyModel is never called.
 On screen the form renders and look fine but nothing gets written back.

 Would appreciate another pair of eyes on this.


 IModel propertyTypes = new LoadableDetachableModel() {
 protected Object load() {
 return userService.allPropertyTypes();
 }
 };

 ListView dynamicProperties = new
 ListView(dynamicProperties, propertyTypes) {

 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(valueField.getId(;
 item.add(label);

 }

 protected IModel getListItemModel(IModel
 listViewModel, int index) {
 PropertyType pt = (PropertyType)
 super.getListItemModel(listViewModel, index).getObject(null);
 return new CompoundPropertyModel(new
 PersonPropertyModel(EditTeamPersonPanel.this.getModel(), pt));
 }

 }.setReuseItems(true);



 public class PersonPropertyModel extends AbstractModel {

 private final IModel teamPerson;
 private final PropertyType propertyType;

 public PersonPropertyModel(IModel teamPersonModel,
 PropertyType propertyType) {
 this.teamPerson = teamPersonModel;
 this.propertyType = propertyType;
 }

 public Object getObject(Component c) {
 logger.info(Calling getObject for component:  + c.getId());
 TeamPerson tp = (TeamPerson) teamPerson.getObject(c);
 Person person = tp.getPerson();
 PersonProperty pp = person.getPropertyOfType(propertyType);
 if (pp == null) {
 logger.info(Adding new property);
 pp = new PersonProperty();
 pp.setPerson(person);
 pp.setPropertyType(propertyType);
 }
 return pp;
 }

 public void setObject(Component c, Object o) {
 TeamPerson tp = (TeamPerson) teamPerson.getObject(c);
 Person person = tp.getPerson();
 logger.info(Calling setObject for property:  +
 ((PersonProperty) o).getPropertyType().getName());
 person.setPropertyOfType((PersonProperty) o);
 }


 public void detach() {
 super.detach();
 teamPerson.detach();
 }
 }

 /Mats

 -
 Using Tomcat but need to do more? Need to support web services, security?
 Get stuff done quickly with pre-integrated technology to make your job easier
 Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
 http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user



-- 
Download Wicket 1.2.1 now! - http://wicketframework.org

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Form-question

2006-08-14 Thread Mats Norén
Not really, I'm not using any Ajax-stuff or anything like that.
How do you mean?

/Mats


On 8/14/06, Gwyn Evans [EMAIL PROTECTED] wrote:
 Does this thread apply?
 (http://www.nabble.com/ajax-failed-to-update-a-component-%28wicket-1.2%29-tf1844050.html#a5033398)
 /Gwyn

 On 13/08/06, Mats Norén [EMAIL PROTECTED] wrote:
  What I want the following code to do is to iterate all propertyTypes
  and create or lookup the appropriate property on my Person-object and
  create a TextField for each one.
 
  I've defined a model for the propertyTypes and a model for a
  TeamPerson-object which contains my Person.
 
  Everything works fine except that the setObject(Component c, Object o)
  in  PersonPropertyModel is never called.
  On screen the form renders and look fine but nothing gets written back.
 
  Would appreciate another pair of eyes on this.
 
 
  IModel propertyTypes = new LoadableDetachableModel() {
  protected Object load() {
  return userService.allPropertyTypes();
  }
  };
 
  ListView dynamicProperties = new
  ListView(dynamicProperties, propertyTypes) {
 
  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(valueField.getId(;
  item.add(label);
 
  }
 
  protected IModel getListItemModel(IModel
  listViewModel, int index) {
  PropertyType pt = (PropertyType)
  super.getListItemModel(listViewModel, index).getObject(null);
  return new CompoundPropertyModel(new
  PersonPropertyModel(EditTeamPersonPanel.this.getModel(), pt));
  }
 
  }.setReuseItems(true);
 
 
 
  public class PersonPropertyModel extends AbstractModel {
 
  private final IModel teamPerson;
  private final PropertyType propertyType;
 
  public PersonPropertyModel(IModel teamPersonModel,
  PropertyType propertyType) {
  this.teamPerson = teamPersonModel;
  this.propertyType = propertyType;
  }
 
  public Object getObject(Component c) {
  logger.info(Calling getObject for component:  + c.getId());
  TeamPerson tp = (TeamPerson) teamPerson.getObject(c);
  Person person = tp.getPerson();
  PersonProperty pp = person.getPropertyOfType(propertyType);
  if (pp == null) {
  logger.info(Adding new property);
  pp = new PersonProperty();
  pp.setPerson(person);
  pp.setPropertyType(propertyType);
  }
  return pp;
  }
 
  public void setObject(Component c, Object o) {
  TeamPerson tp = (TeamPerson) teamPerson.getObject(c);
  Person person = tp.getPerson();
  logger.info(Calling setObject for property:  +
  ((PersonProperty) o).getPropertyType().getName());
  person.setPropertyOfType((PersonProperty) o);
  }
 
 
  public void detach() {
  super.detach();
  teamPerson.detach();
  }
  }
 
  /Mats
 
  -
  Using Tomcat but need to do more? Need to support web services, security?
  Get stuff done quickly with pre-integrated technology to make your job 
  easier
  Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
  http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
  ___
  Wicket-user mailing list
  Wicket-user@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/wicket-user
 


 --
 Download Wicket 1.2.1 now! - http://wicketframework.org

 -
 Using Tomcat but need to do more? Need to support web services, security?
 Get stuff done quickly with pre-integrated technology to make your job easier
 Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
 http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user


-
Using Tomcat but need to do more? Need to support web services, 

Re: [Wicket-user] Form-question

2006-08-13 Thread Mats Norén
What I want the following code to do is to iterate all propertyTypes
and create or lookup the appropriate property on my Person-object and
create a TextField for each one.

I've defined a model for the propertyTypes and a model for a
TeamPerson-object which contains my Person.

Everything works fine except that the setObject(Component c, Object o)
in  PersonPropertyModel is never called.
On screen the form renders and look fine but nothing gets written back.

Would appreciate another pair of eyes on this.


IModel propertyTypes = new LoadableDetachableModel() {
protected Object load() {
return userService.allPropertyTypes();
}
};

ListView dynamicProperties = new
ListView(dynamicProperties, propertyTypes) {

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(valueField.getId(;
item.add(label);

}

protected IModel getListItemModel(IModel
listViewModel, int index) {
PropertyType pt = (PropertyType)
super.getListItemModel(listViewModel, index).getObject(null);
return new CompoundPropertyModel(new
PersonPropertyModel(EditTeamPersonPanel.this.getModel(), pt));
}

}.setReuseItems(true);



public class PersonPropertyModel extends AbstractModel {

private final IModel teamPerson;
private final PropertyType propertyType;

public PersonPropertyModel(IModel teamPersonModel,
PropertyType propertyType) {
this.teamPerson = teamPersonModel;
this.propertyType = propertyType;
}

public Object getObject(Component c) {
logger.info(Calling getObject for component:  + c.getId());
TeamPerson tp = (TeamPerson) teamPerson.getObject(c);
Person person = tp.getPerson();
PersonProperty pp = person.getPropertyOfType(propertyType);
if (pp == null) {
logger.info(Adding new property);
pp = new PersonProperty();
pp.setPerson(person);
pp.setPropertyType(propertyType);
}
return pp;
}

public void setObject(Component c, Object o) {
TeamPerson tp = (TeamPerson) teamPerson.getObject(c);
Person person = tp.getPerson();
logger.info(Calling setObject for property:  +
((PersonProperty) o).getPropertyType().getName());
person.setPropertyOfType((PersonProperty) o);
}


public void detach() {
super.detach();
teamPerson.detach();
}
}

/Mats

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


[Wicket-user] Form-question

2006-08-04 Thread Mats Norén
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 SetPersonProperty
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.phpp=sourceforgeCID=DEVDEV
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Form-question

2006-08-04 Thread Igor Vaynberg
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 SetPersonPropertyA 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 byshowing them all on screen.In a previous email to the list there was an example of aMaster-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 = newFormComponentFeedbackBorder(feedback);feedbackBorder.setRenderBodyOnly
(true);feedbackBorder.add(valueField);item.add(feedbackBorder);Label label = new Label(propertyType.name);
label.add(new AttributeModifier(for, true, newModel(item.getId(;item.add(label);}protected IModel getListItemModel(IModellistViewModel, int index) {
return newCompoundPropertyModel(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 allthe possible ones, ie the PropertyType:s and get the values from thePersonProperty 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 ITJoin SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cashhttp://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___Wicket-user mailing listWicket-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.phpp=sourceforgeCID=DEVDEV___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Form-question

2006-08-04 Thread Mats Norén
Thanks,  I'll give it a try!

On 8/4/06, Igor Vaynberg [EMAIL PROTECTED] wrote:
 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 SetPersonProperty
 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.phpp=sourceforgeCID=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.phpp=sourceforgeCID=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.phpp=sourceforgeCID=DEVDEV
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user