DavidVdd
DavidVdd

Reputation: 1018

Wicket ajax update component behavior?

I have overriden the rowitem from my DefaultDataTable to add some onClick behavior.

        @Override
        protected Item newRowItem(String id, int index, IModel model) {
             //return super.newRowItem(id, index, model);
            final Item<SearchResult> rowItem = super.newRowItem(id, index,model);
            rowItem.add(new AjaxEventBehavior ("onclick") {
               @Override
               protected void onEvent(AjaxRequestTarget target){
                  WebMarkupContainer wmc = new WebMarkupContainer("myTest");
                  target.add(wmc); //this doesn't work
                  add(wmc); //works but only when I refresh the page
               }
            });
            return rowItem;
        }

        <object wicket:id="myTest" data="" border="1" width="100%" height="600px"></object>

When a click happens I would like to update the data of the object and reload the object. The object is a Pdf file. The Pdf doesn't seem to reload if I use the target. I have set

         wmc.setOutputMarkupId(true);

But that doesn't seem to help.

How could I make it so the user doesn't have to refresh the page???

I just started using Wicket and Ajax so I'm a beginner.

Upvotes: 2

Views: 6334

Answers (1)

Christoph Leiter
Christoph Leiter

Reputation: 9345

You should add the original container to the AjaxRequestTarget instead of creating a new one. Make sure the container uses a dynamic model so that the value is actually updated when the component is redrawn via AJAX.

Upvotes: 7

Related Questions