问题
I need to AJAXfully filter by users list of PsDoctrans
which is shown in a Wicket DataView
.
final TextField txtName= new TextField("user");
final PSDocDP dp = new PSDocDP("username");
DataView<PsDoctrans> dataView = new DataView<PsDoctrans>("unproc", dp)
{
@Override
protected void populateItem(final Item<PsDoctrans> item)
...
};
PSDocDP
is:
public class PSDocDP extends SortableDataProvider<PsDoctrans>
{...}
final WebMarkupContainer wmc = new WebMarkupContainer("container");
wmc.add(dataView);
wmc.setOutputMarkupId(true);
AjaxButton butFind=new AjaxButton("find"){
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form)
{
String value=(String)txtName.getModelObject();
dp = new PSDocDP(value);
target.addComponent(wmc);
}
};
After submitting, nothing changes. The program shows some data, but it isn't filtering. How can I make filtering happen?
回答1:
I use constructions comparable to this, so it should work.
Do you really create a new "dp" object in the callback. You should simply change the state of the data provider - how should the component ever get the changed provider.
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form)
{
String value=(String)txtName.getModelObject();
--> dp.setName(value);
target.addComponent(wmc);
}
来源:https://stackoverflow.com/questions/4561045/how-can-i-update-a-wicket-dataview-with-ajax