It is always 0 because onpopulate is not called until render time,
where the value of the label is set to a fixed string in your model.
the solution is to wrap totalCredit in a model. also make sure to
reset it 0 again in the onpopulate if the item index =0 or the value
will continue to increase with each rendering.

Maurice

On Tue, May 6, 2008 at 10:13 AM, tsuresh <[EMAIL PROTECTED]> wrote:
>
>  Hello all
>   I need to sum the values of the tabular data in listview. I tried like this
>  but it doesnot work. How should i do it. I need to get the totalCredit added
>  from the list but its always = 0 , where am i wrong, please help
>
>
>     private int totalCredit = 0;
>
>     public AccountPanel(String id, String user) {
>         super(id);
>         try {
>             accountList = Bill.listUserWise(user);
>         } catch (SQLException e) {
>
>         }
>
>         final ListView data = new ListView("rows", accountList) {
>
>             public void populateItem(final ListItem item) {
>                 Bill bill = (Bill) item.getModelObject();
>                 item.add(new Label("date", bill.getName()));
>                 String creditValue = String.valueOf(bill.getCredit());
>                 totalCredit = totalCredit + bill.getCredit();
>                 item.add(new Label("credit", creditValue));
>                 }
>         };
>
>         add(data);
>         add(new Label("cr", String.valueOf(totalCredit)));
>
>  thanks
>  tsuresh
>  --
>  View this message in context: 
> http://www.nabble.com/Add-list-item-values-tp17078026p17078026.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]

Reply via email to