Thanks that worked just fine.
- Brill
On 11-Mar-09, at 4:08 AM, triswork wrote:
Hi
It isn't working because you are using a static model on your Label.
So, when your label component calls the model's getObject() method,
the
underlying object is the String value originally returned by
adder.getValue(), NOT the actual adder itself.
An easy fix is to make your model dynamic. Something like this
should do it:
add(new Label("mySum", new Model()
{
@Override
public Object getObject()
{
return adder.getValue();
}
});
Have a look at PropertyModels for a more elegant solution :)
Brill Pappin wrote:
I have an issue I'm sure someone else must have come across at one
point or another.
It's essentially to do with rendering order. Take the following
example:
final BigDecimalCalc adder = new BigDecimalCalc();
add(new ListView<...>("myListView", yModel(...)) {
...
protected void populateItem(ListItem<...> item) {
...
BigDecimal total = ...;
adder.add(total);
}}
});
add(new Label("mySum", adder.getValue());
So of course the mySum label gets rendered before the listView items
have been rendered, which in turn means that the result for mySum is
always zero.
Now I could likely pre-load my data and make my calculations before
sending it to the components, but it seems to me that since I'm
iterating over the data anyway, I'd like to use that loop for doing
something like sum the elements in the list.
Does anyone have a solution for this or is there some Wicket magic I
haven't found yet?
- Brill
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
--
View this message in context:
http://www.nabble.com/counting-summing-items-in-a-list-view-tp22448946p22450359.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]