Hi
I have a form that I add to it web markup container and attach  a data view
and then ajax button to a form.
I want to populate this DataView on ajax button onSubmit. How to do it
correctly?
I saw this answer on Stack Overflow which is almost exactly what I want but
it didn't solve my case.
https://stackoverflow.com/questions/24506426/wicket-dataview-refresh-with-ajaxbutton
Here comes the code.

List<Log> logs = new ArrayList<Log>();

                logListP = new ListDataProvider<Log>() {
                        private static final long serialVersionUID = 1L;
                        @Override
                        protected List<Log> getData() {
                                return logs;
                        }
                };
                
                logListP = new ListDataProvider<Log>() {
                         protected List<Log> getData() {
                                return logs;
                            }
                };
                
                DataView<Log> dataView = new DataView<Log>("rows", logListP,
ITEMS_PER_PAGE) {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void populateItem(final Item<Log> item) {
                                Log log = item.getModelObject();
                                item.add(new Label("id", log.getId()));
                                item.add(new Label("id2", log.getSize()));
                                item.add(new Label("id3", log.getCheckSum()));
                        }
                };

                WebMarkupContainer wmc = new WebMarkupContainer("container");
                dataView.setOutputMarkupId(true);
                wmc.setOutputMarkupId(true);
                wmc.add(dataView);

                AjaxButton buttonReadDtc = new AjaxButton("buttonRead") {

                        private static final long serialVersionUID = 1L;

                        @Override
                        protected void onSubmit(AjaxRequestTarget target, 
Form<?> form) {
                                if (target != null) {
                                        try {
                                        List<Log> logs = getLogFilesData();
                                        logListP = new 
ListDataProvider<Log>(logs);
                                        } catch (IOException e) {
                                                e.printStackTrace();
                                        }
                                        target.add(wmc);
                                }
                        }
                };

                form.add(wmc);
                form.add(buttonRead);

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to