No, it sends a request somewhere and gets a response, I can't change the response. is there any other way? or maybe I need to change the model?
On Fri, Feb 18, 2011 at 10:52 AM, Sven Meier <[email protected]> wrote: > > Hi, > > I assume your query model loads the records from a db? Then persist the new > Myrecord first (via a DAO and/or service layer) and then detach the model > explicitely to let it query a fresh state. > > WebMarkupContainer myPanel = new WebMarkupContainer("myPanel"); > myPanel.setOutputMarkupId(true); > form.add(myPanel); > > final QueryModel model = (QueryModel)getDefaultModel(); > > final ListView lv = new ListView("rows", model) { > @Override > protected void populateItem(ListItem item) { > // don't pull anything out of models just to place it into > another model, > // otherwise you're just increasing your session size > item.add(new TextField<Integer>("value", > new PropertyModel<Integer>(item.getModel(), "value"), > Integer.class)); > } > } > myPanel.add(lv); > > AjaxSubmitLink addLink = new AjaxSubmitLink("addRow") { > @Override > public void onSubmit(AjaxRequestTarget target, Form<?> form) { > // let you service layer persist the new record > dao.persist(new Myrecord()); > // let the model query a fresh state > model.detach(); > > if (target != null) { > target.addComponent(myPanel); > target.addComponent(addLink); > } > } > public boolean isVisible() { > // although disdained recently IMHO this is a perfect place to > override > isVisible() > // and be always up-to-date > return super.isVisible() && model.getObject().size() < 10 > } > }; > addLink.setDefaultFormProcessing(false); > form.add(addLink); > > HTH > > Sven > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/LoadableDetachableModel-tp3312829p3312947.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- Anna Simbirtsev (416) 729-7331 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
