Here the code, html and Java fragments, for the <tr>. /Anders
Timo Rantalaiho wrote:
On Mon, 29 Sep 2008, Anders Peterson wrote:
I'm using OnChangeAjaxBehavior with a TextField. The TextField is in a
table cell that is repeated using a ListView. When I change the value of
one of the TextFields more than one of the underlying models get updated
- the one that was supposed to be updated and all following in the list.
If I modify the first TextField then all underlying models get the same
value. If I modify the second then all except the first...
Hello,
It sounds like all your TextFields models would be connected
to each other. Show us the code and we'll see.
Best wishes,
Timo
ListView<BLView> tmpViews = new ListView<BLView>(ID.VIEWS,
this.getPortfolio().getViews()) {
@Override
public void populateItem(ListItem<BLView> aViewsListItem) {
final BLView tmpView = aViewsListItem.getModelObject();
final ContextLabel<Number> tmpTotalWeightLabel = new
ContextLabel<Number>(ID.TOTAL_WEIGHTS, new PropertyModel<Number>(tmpView,
ID.TOTAL_WEIGHTS), StandardType.PERCENT);
tmpTotalWeightLabel.setOutputMarkupId(true);
aViewsListItem.add(new TextField<String>(ID.NAME, new
PropertyModel<String>(tmpView, ID.NAME)));
aViewsListItem.add(new DeleteView(ID.DELETE, new
Model<BLView>(tmpView)));
LoadableDetachableModel<Number> tmpMarketReturnModel = new
LoadableDetachableModel<Number>() {
@Override
protected BigDecimal load() {
return
myPage.getBlackLittermanModel().calculatePortfolioReturn(tmpView.getWeightList());
}
};
aViewsListItem.add(new
ContextLabel<Number>(ID.PORTFOLIO_RETURN, tmpMarketReturnModel,
StandardType.PERCENT));
aViewsListItem.add(new ContextTextField<Number>(ID.RETURN, new
PropertyModel<Number>(tmpView, ID.RETURN), StandardType.PERCENT));
ListView<ViewWeight> tmpViewWeightTextFields = new
ListView<ViewWeight>(ID.WEIGHTS, tmpView.getViewWeights()) {
@Override
protected void populateItem(ListItem<ViewWeight>
aViewWeightsListItem) {
final ViewWeight tmpViewWeight =
aViewWeightsListItem.getModelObject();
ContextTextField<Number> tmpWeightTextField = new
ContextTextField<Number>(ID.WEIGHT, new PropertyModel<Number>(tmpViewWeight,
ID.WEIGHT), StandardType.PERCENT);
aViewWeightsListItem.add(tmpWeightTextField);
tmpWeightTextField.add(new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget
aWeightTextFieldChangeTarget) {
System.out.println("AJAX!");
System.out.println("THIS ViewWeight: " +
tmpViewWeight);
for (ViewWeight tmpVW :
tmpViewWeight.getView().getViewWeights()) {
System.out.println("LOOP ALL ViewWeights: "
+ tmpVW);
}
System.out.println();
aWeightTextFieldChangeTarget.addComponent(tmpTotalWeightLabel);
}
});
}
};
aViewsListItem.add(tmpViewWeightTextFields);
aViewsListItem.add(tmpTotalWeightLabel);
};
};
<tr wicket:id="views">
<td scope="col"><input name="name" type="text" id="name" size="16"
wicket:id="name" /></td>
<td scope="col"><a wicket:id="delete"
href="/se/optimatika/blapp/gui/PgInputViews.html"><img src="images/minus.gif"
alt="Delete View" width="14" height="14" hspace="1" vspace="3" border="0"
/></a></td>
<td scope="col"><div align="right"><span
wicket:id="portfolioReturn">1.2%</span></div></td>
<td scope="col"><div align="center">
<div align="right">
<input name="return" type="text" id="return" size="8"
wicket:id="return" />
</div>
</div></td>
<th scope="col">@</th>
<td wicket:id="weights" scope="col"><div align="right">
<input name="weight" type="text" id="weight" size="7" maxlength="8"
wicket:id="weight" />
</div></td>
<th scope="col">=</th>
<td scope="col"><div align="right"><span
wicket:id="totalWeights">100.00%</span></div></td>
</tr>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]