Hi Matt;
Make a dynamic dataprovider as follows:
public abstract class UserDataProvider extends SortableDataProvider<User> {
public UserDataProvider(){
setSort("id", SortOrder.ASCENDING);
}
public Iterator<User> iterator(int start, int count) {
return User.getItems(getSearchParam()).iterator() ;
}
public IModel<User> model(User user) {
return new Model<User>(user);
}
public int size() {
return User.getItemCount(getSearchParam());
}
public abstract String getSearchParam();
}
Not the abstract method for getting the filtering parameter.
Then use it like this:
UserDataProvider dp = new UserDataProvider() {
@Override
public String getSearchParam() {
return searchParam
}
};
The search parameter is recalculated everytime the table is refreshed.
Hope you get the idea.
Josh.
On Sun, Dec 4, 2011 at 12:19 AM, mashleyttu <[email protected]> wrote:
> Hi,
>
> I'm using an AjaxFallbackDefaultDataTable and I am trying to update the
> Data
> Provider during an Ajax call back. A little more details is I have a
> TextField with an AjaxFormComponentUpdatingBehavior("onkeyup") behavior
> attached for filtering results in my AjaxFallbackDefaultDataTable.
>
> Long story short, is I do not know how to update the Data Provider for the
> Table and have the filtered results displayed in the web browser. I've had
> to settle on creating a new AjaxFallbackDefaultDataTable and use the
> replaceWith function to display he results. Please see code below.
>
> TextField txtIncidentFilter = (TextField)
> IncidentListViewPanel.this.get("rowSearch:txtIncidentFilter");
> String searchQuery = (String)
> txtIncidentFilter.getDefaultModelObject();
> WebMarkupContainer cntIncidentList
> = (WebMarkupContainer)
> IncidentListViewPanel.this.get("cntIncidentList");
> AjaxFallbackDefaultDataTable cmp =
> (AjaxFallbackDefaultDataTable)
> cntIncidentList.get("tblIncidents");
>
>
> myListParams.setQueryString("%"+Commons.nvl(searchQuery,"")+"%".toLowerCase());
> AjaxFallbackDefaultDataTable
> newIncidentFilterResults = new
> AjaxFallbackDefaultDataTable("tblIncidents",columns,new
> SortableIncidentDataProvider("INCIDENT_TS",myListParams),rowCount);
>
> cmp.replaceWith(newIncidentFilterResults);
> cmp = newIncidentFilterResults;
> cmp.setOutputMarkupId(true);
> target.addComponent(cmp);
>
> target.addComponent(cntIncidentList);
>
> This works fine but I would think requires a lot of extra processing/memory
> etc, where you should simply be able to update the dataprovider for the
> component.
>
> Does anyone know how to provide a new data provider for a
> AjaxFallbackDefaultDataTable component?
>
> Using wicket 1.4.15 in PROD.
>
> Thanks,
> Matt
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-Refresh-Data-Provider-tp4154899p4154899.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>