Hello, Please check the image. Hope this is helpful. Thank you. On Mon, Jul 4, 2016 at 9:44 AM, Sven Meier [via Apache Wicket] < ml-node+s1842946n4675021...@n4.nabble.com> wrote:
> Hi, > > I'm not sure which code is calling #isVisible() here, a stacktrace would > help to identify the caller. > > Nevertheless it's quite normal for #isVisible() to be called a number of > times. Thus it's a recommended practice to override #onConfigure() > instead: > > @Override > public void onConfigure() { > List<Doc> docList = documentsModel.getObject(); > setVisible(docList != null && docList.size() > 0); > } > > Have fun > Sven > > > > On 03.07.2016 21:36, Iamuser wrote: > > > Hello, > > Please help me with the following situation: > > I'm using wicket 6. > > I have a page and a form. > > On this form I have an input, and when user hits Upload button, the list > > with the inputs should be updated. > > > > However, there is a strange behaviour: > > 1. when hitting the submit button, the onsubmit method is not > immediatelly > > called, but instead > > the isVisible() method is called on a repeated number of times, which > then > > calls Load() of the LoadableDetachableModel is called. > > 2. only after that the onSubmit() is finally called. > > > > But this behaviour, because of the isVisible() method being called > before > > onSubmit() does not display the new item to the list on the page. Only > after > > a new refresh of the page it is finally displayed. > > > > Here is the html and the java code: > > > > private class UploadForm extends Form<Doc> { > > > > private static final long serialVersionUID = 1L; > > > > public UploadForm(String id, IModel<Doc> docmodel) { > > super(id, docmodel); > > TextField<String> fileDescription = new > > TextField<String>("fileDescription", new > > PropertyModel<String>(getModelObject(), "description")); > > add(fileDescription); > > > > final LoadableDetachableModel<List<Doc>> documentsModel = new > > LoadableDetachableModel<List<Doc>>() { > > > > private static final long serialVersionUID = 1L; > > > > @Override > > protected List<Doc> load() { > > return SpringCtx.getAppDB(DocDao.class).selectByParentId(238); > > } > > }; > > > > final WebMarkupContainer documentsContainer = new > > WebMarkupContainer("documentsContainer"); > > documentsContainer.setOutputMarkupId(true); > > add(documentsContainer); > > > > documentsContainer.add(new ListView<Doc>("documentList", documentsModel) > > { > > private static final long serialVersionUID = 1L; > > > > @Override > > protected void populateItem(ListItem<Doc> item) { > > item.add(new Label("document", > > item.getModelObject().getDescription())); > > } > > @Override > > public boolean isVisible() { > > List<Doc> docList = documentsModel.getObject(); > > return docList != null && docList.size() > 0; > > } > > }.setOutputMarkupId(true)); > > } > > > > @Override > > public void onSubmit() { > > logger.debug("this is onsubmit()"); > > > > Doc d = new Doc(); > > > > try { > > d.setFileName("test_fn"); > > d.setId(SpringCtx.getAppDB(DocDao.class).selectNextId()); > > d.setFileUrl("url"); > > d.setDescription(getModelObject().getDescription()); > > d.setParentId(238); > > > > SpringCtx.getAppDB(DocDao.class).insert(d); > > getModelObject().clear(); > > feedbackPanel.info(getString("upload.document.success")); > > } catch (Exception e) { > > logger.error("Error uploading user file", e); > > feedbackPanel.error(getString("upload.document.error") + " " + > > ExceptionUtils.getRootCauseMessage(e)); > > } > > } > > > > }; > > > > <http://apache-wicket.1842946.n4.nabble.com/file/n4675020/1.png> > > > > Please help me understand the issure. Thank you in advance. > > > > > > -- > > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/onsubmit-gets-called-after-page-reload-tp4675020.html > > Sent from the Users forum mailing list archive at Nabble.com. > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [hidden email] > <http:///user/SendEmail.jtp?type=node&node=4675021&i=0> > > For additional commands, e-mail: [hidden email] > <http:///user/SendEmail.jtp?type=node&node=4675021&i=1> > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > <http:///user/SendEmail.jtp?type=node&node=4675021&i=2> > For additional commands, e-mail: [hidden email] > <http:///user/SendEmail.jtp?type=node&node=4675021&i=3> > > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://apache-wicket.1842946.n4.nabble.com/onsubmit-gets-called-after-page-reload-tp4675020p4675021.html > To unsubscribe from onsubmit gets called after page reload, click here > <http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675020&code=c3VwZXJiaXNzaW1hQGdtYWlsLmNvbXw0Njc1MDIwfC01MzM2MjU4NzI=> > . > NAML > <http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > 3.png (26K) <http://apache-wicket.1842946.n4.nabble.com/attachment/4675027/0/3.png> -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/onsubmit-gets-called-after-page-reload-tp4675020p4675027.html Sent from the Users forum mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org