On Thu, May 27, 2010 at 10:53 AM, sahuja <sadhna.ah...@nisc.coop> wrote:

>
> Thanks, Igor. Copied below is the implementation for my toolbar. Could you
> please take a look and see if you can spot a problem with it?
>
> public class TotalsToolbar extends AbstractToolbar
> {
>
>    public TotalsToolbar(final DataTable table, final IDataProvider
> dataProvider)
>    {
>        super(table);
>
>        RepeatingView totals = new RepeatingView("totals");
>        add(totals);
>
>        AbstractReportingBean row =
> (AbstractReportingBean)dataProvider.iterator(0, 1).next();
>        final IColumn[] columns = table.getColumns();
>        for (int i = 0; i < columns.length; i++)
>        {
>            final IColumn column = columns[i];
>
>            WebMarkupContainer item = new
> WebMarkupContainer(totals.newChildId());
>            totals.add(item);
>
>            WebMarkupContainer total = new WebMarkupContainer("total");
>
>            item.add(total);
>            item.setRenderBodyOnly(true);
>
> *                String val =
> row.getStringForFieldNamed(column.getSortProperty());
>                if (val == null || val.length() == 0) {
>                    val = "&nbsp;";
>                    total.add(new Label("value",
> val).setEscapeModelStrings(false));
>                } else
>                    total.add(new Label("value", val));
> *
>        }
>    }
> }
>
>
You're not using a model for your label - so you are "pushing" data into it
on creation and never changing the data after it's initially created.  This
is easily learned / proven if you put a breakpoint there where you are
creating your label.

Actually, now that I look at it, you're also not using a model for your
columns in your toolbar.  I'm not sure what your AbstractReportingBean is,
but you will probably also need to change your RepeatingView to something
that takes an IModel<List> and creates the columns on the fly - or else
you'll get old data.

Here's an example for the Label - but you'll have to do the repeater on your
own.

total.add(new Label("value", new AbstractReadOnlyModel<String>() {
  String getObject() {
    String val = row.getStringForFieldNamed(column.getSortProperty());;
    return StringUtils.isEmpty(val) ? "nbsp;" : val;
  }
});
-- 
Jeremy Thomerson
http://www.wickettraining.com

Reply via email to