You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by tech7 <te...@gmail.com> on 2011/03/22 12:16:25 UTC
ListMultipleChoice Binding List Problem
Hi,
I have a problem constructing ListMultipleChoice objects inside the loop.
I had written the code as:
List groupModelsDrop = new ArrayList();
propertyLoop2 = new Loop("properties2", propertyList2.size()) {
@Override
protected void populateItem(final LoopItem propertyItem) {
final Property property2 =
propertyList2.get(propertyItem.getIteration());
propertyItem.add(new Label("propertyName2", property2.getName()));
final List itemList2 = new ArrayList(property2.getItems());
IModel<Collection<Item>> allItemsModel = new
PropertyModel<Collection<Item>>( new Model(),
groupModelsDrop.get(propertyItem.getIteration())
);
final ListMultipleChoice itemSelect = new ListMultipleChoice(
"itemList",
allItemsModel,
itemList2,
new IChoiceRenderer() {
@Override
public String getIdValue(Item item, int index) {
return String.valueOf(item.getId());
}
@Override
public String getDisplayValue(Item item) {
return item.getName();
}
});
propertyItem.add(itemSelect);
};
};
but the problem is; when i submit the form it gives an error "WicketMessage:
Attempted to set property value on a null object. Property expression:
groupModelsDrop.get(propertyItem.getIteration()) " like that.
Where is my fault?
I need your suggestions.
With my best regards.
-----
Wicket-Java
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/ListMultipleChoice-Binding-List-Problem-tp3396083p3396083.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: ListMultipleChoice Binding List Problem
Posted by Andrea Del Bene <ad...@ciseonweb.it>.
Hi tech7,
in these lines:
IModel<Collection<Item>> allItemsModel = new
PropertyModel<Collection<Item>>( new Model(),
groupModelsDrop.get(propertyItem.getIteration()));
you are building a property model from another generic model (i.e. new
Model()) without an instance inside it. So when property model tries to
resolve property expression, it gets a null reference.
> Hi,
> I have a problem constructing ListMultipleChoice objects inside the loop.
> I had written the code as:
> List groupModelsDrop = new ArrayList();
> propertyLoop2 = new Loop("properties2", propertyList2.size()) {
>
> @Override
> protected void populateItem(final LoopItem propertyItem) {
> final Property property2 =
> propertyList2.get(propertyItem.getIteration());
> propertyItem.add(new Label("propertyName2", property2.getName()));
>
> final List itemList2 = new ArrayList(property2.getItems());
> IModel<Collection<Item>> allItemsModel = new
> PropertyModel<Collection<Item>>( new Model(),
>
> groupModelsDrop.get(propertyItem.getIteration())
> );
> final ListMultipleChoice itemSelect = new ListMultipleChoice(
> "itemList",
> allItemsModel,
> itemList2,
> new IChoiceRenderer() {
>
> @Override
> public String getIdValue(Item item, int index) {
> return String.valueOf(item.getId());
> }
>
> @Override
> public String getDisplayValue(Item item) {
> return item.getName();
> }
> });
> propertyItem.add(itemSelect);
> };
> };
>
>
> but the problem is; when i submit the form it gives an error "WicketMessage:
> Attempted to set property value on a null object. Property expression:
> groupModelsDrop.get(propertyItem.getIteration()) " like that.
> Where is my fault?
> I need your suggestions.
> With my best regards.
>
> -----
> Wicket-Java
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/ListMultipleChoice-Binding-List-Problem-tp3396083p3396083.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org