Re: Force toolbar to update on page refresh

2010-05-27 Thread sahuja

Jeremy, I am not really sure what you mean by using a model that gets the
columns on every repaint, but here's how I have changed my code now.

public TotalsToolbar(final DataTable table, final IModel
dataProviderModel)
{
super(table);

WebMarkupContainer totals = new WebMarkupContainer("totals");
add(totals);

AbstractReportingBean row =
(AbstractReportingBean)dataProviderModel.getObject();

List totalList = new ArrayList();
final IColumn[] columns = table.getColumns();
for (int i = 0; i < columns.length; i++)
{
   final IColumn column = columns[i];
   String val =
row.getStringForFieldNamed(column.getSortProperty());
   if (val == null || val.length() == 0) {
   val = " ";
   }
   totalList.add(val);
}

ListView listView = new ListView("total", totalList){
protected void populateItem(ListItem item) {
String totalItem = (String) item.getModelObject();
item.add(new Label("value",
totalItem.getValue()).setEscapeModelStrings(false));
}
};

totals.add(listView);
return;
}

I changed the way I was creating my toolbar to use a model wrapped around
the data.

public GrandTotalsDataTable(String id, final List columns,
ISortableDataProvider sortableDataProvider, IDataProvider
dataProvider,
int rowsPerPage)
{
super(id, columns, sortableDataProvider, rowsPerPage);
addBottomToolbar(new TotalsToolbar(this,
dataProvider.model(dataProvider.iterator(0, 1).next(;
}

And, here is my markup for the TotalsToolbar:

  
[span wicket:id="totals">
  
  [span wicket:id="value">[amount][/span>
  
[/span>
  


(Changing the '<' before span tags to display it).

BTW, I tried to put breakpoints like you suggested, but interestingly when I
hit F5, the debugger doesn't hit any of my code. I do see the table being
updated though...

Thanks.
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Force-toolbar-to-update-on-page-refresh-tp2233347p2233773.html
Sent from the Wicket - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Force toolbar to update on page refresh

2010-05-27 Thread sahuja

Thanks for your suggestions, Jeremy and Igor.

I tried to use a ListView. With that I succeeded in refreshing the toolbar
on a bookmarkable page, but not a page that I navigated through the
Navigation Toolbar.
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Force-toolbar-to-update-on-page-refresh-tp2233347p2233646.html
Sent from the Wicket - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Force toolbar to update on page refresh

2010-05-27 Thread sahuja

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 = " ";
total.add(new Label("value",
val).setEscapeModelStrings(false));
} else
total.add(new Label("value", val));
 
}
}
}

This is how I add the toolbar to my table:

public class GrandTotalsDataTable extends DefaultDataTable {
public GrandTotalsDataTable(String id, final List columns,
ISortableDataProvider sortableDataProvider, IDataProvider
dataProvider,
int rowsPerPage)
{
super(id, columns, sortableDataProvider, rowsPerPage);
addBottomToolbar(new TotalsToolbar(this, dataProvider));
}

}


Thanks.
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Force-toolbar-to-update-on-page-refresh-tp2233347p2233368.html
Sent from the Wicket - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Force toolbar to update on page refresh

2010-05-27 Thread sahuja

Hi,

I have a DefaultDataTable with a BottomToolbar that I wrote to display the
sum of amounts in each column of the table.

If the underlying data changes, and I press F5 to refresh the browser page,
the table reflects the data change, but the toolbar is not refreshed and
continues to display previous amounts.

Is there a way for me to force the toolbar to re-fetch data from its
DataProvider?

Thanks.

-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Force-toolbar-to-update-on-page-refresh-tp2233347p2233347.html
Sent from the Wicket - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org