简体   繁体   中英

How can I update a Wicket DataView with AJAX?

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?

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);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM