Yes - James is right here - it's a loadable detachable model - so it needs
to load the data in order to repopulate the list before deleting the item.

My guess is either you need to call the detach so that on the re-render it
gets reloaded, or you need to make sure your delete is being committed to
the DB before the re-render.  Perhaps the transaction was not committed?

--
Jeremy Thomerson
http://www.wickettraining.com



On Tue, Jan 26, 2010 at 1:14 PM, James Carman
<jcar...@carmanconsulting.com>wrote:

> Doesn't it have to load the model so that it knows what item it's talking
> to?
>
> On Tue, Jan 26, 2010 at 2:12 PM, Riyad Kalla <rka...@gmail.com> wrote:
> > Seems weird to me as well that 'detach' has to be explicitly called. Also
> > still curious why Stephane was seeing the log ordering he did when the
> link
> > was clicked:
> >
> > ============
> > Loading all news
> > News deleted
> > ============
> >
> > I'd expect to see "news deleted" first, from his onClick handler then the
> > "loading all news" caused by the call to "load()" before the response was
> > sent -- in which case it seems he wouldn't have run into this issue in
> the
> > first place.
> >
> > It's entirely possible I'm missing the wicket processing sequence here
> being
> > something else which would explain this.
> >
> > On Tue, Jan 26, 2010 at 9:59 AM, Stéphane Jeanjean <
> > stephane.jeanj...@softeam.com> wrote:
> >
> >>
> >> Thanks Pedro, it's ok now ;-)
> >>
> >> I use LoadableDetachableModel to avoid the call to detach() method. It
> does
> >> not seem that is the right way. Somebody can explain me why ?
> >>
> >> Stéphane
> >>
> >>
> >> Pedro Santos a écrit :
> >>
> >>  by calling getDefaultModel inside onClick, you get an reference to the
> >>> link
> >>> component model. You need to detach the model on your list view. You
> has
> >>> an
> >>> reference to it on your variable "news". So:
> >>> news.getDefaultModel().detach()
> >>> If you need, you can change that variable modifiers or turn it an
> instance
> >>> variable for have acess to it inside your onClick implementation.
> >>>
> >>> On Tue, Jan 26, 2010 at 2:01 PM, Stéphane Jeanjean <
> >>> stephane.jeanj...@softeam.com> wrote:
> >>>
> >>>
> >>>
> >>>> The behaviour is the same with the following code :(
> >>>>
> >>>>
> >>>>                  public void onClick() {
> >>>>                      // TODO : check the refresh issue
> >>>>                      getNewsDao().delete(item.getModelObject());
> >>>>                      ourLogger.debug("News deleted");
> >>>>                      getDefaultModel().detach();
> >>>>                                        }
> >>>>
> >>>>
> >>>> Pedro Santos a écrit :
> >>>>
> >>>>  missing line: call detach method just after delete your item.
> >>>>
> >>>>
> >>>>> On Tue, Jan 26, 2010 at 1:41 PM, Pedro Santos <pedros...@gmail.com>
> >>>>> wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>> Call news.getDefaultModel().detach(), and look for more info about
> >>>>>> detachable models.
> >>>>>>
> >>>>>> http://cwiki.apache.org/WICKET/detachable-models.html
> >>>>>>
> >>>>>> On Tue, Jan 26, 2010 at 1:35 PM, Stéphane Jeanjean <
> >>>>>> stephane.jeanj...@softeam.com> wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> Hi,
> >>>>>>>
> >>>>>>> I don't use Hibernate. My persistence layer uses JDBC.
> >>>>>>>
> >>>>>>> What is strange when I click the delete link, it's the logs order :
> >>>>>>>
> >>>>>>> Loading all news
> >>>>>>> News deleted
> >>>>>>>
> >>>>>>> So it seems that the deletion is done after the data reload :(
> >>>>>>>
> >>>>>>> Stéphane
> >>>>>>>
> >>>>>>>
> >>>>>>> Riyad Kalla a écrit :
> >>>>>>>
> >>>>>>>  Stephane,
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> I'll let someone smarter than me address the wicket issue of
> removing
> >>>>>>>> the
> >>>>>>>> item from the ListView and seeing if that helps -- but is there a
> >>>>>>>> chance
> >>>>>>>> you
> >>>>>>>> are using Hibernate and the Level 2 ehcache plugin or any
> 2nd-level
> >>>>>>>> caching
> >>>>>>>> with your persistence code? I ask because I've seen code like this
> "I
> >>>>>>>> don't
> >>>>>>>> see my changes until the 2nd refresh!" a lot with folks using 2nd
> >>>>>>>> level
> >>>>>>>> caches and not seeing immediate persistence of those changes.
> >>>>>>>>
> >>>>>>>> On Tue, Jan 26, 2010 at 7:57 AM, Stéphane Jeanjean <
> >>>>>>>> stephane.jeanj...@softeam.com> wrote:
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> Please find my code just below :
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> public class NewsListPage  {
> >>>>>>>>>
> >>>>>>>>>  protected static transient NewsDao myNewsDao;
> >>>>>>>>>
> >>>>>>>>>  public NewsListPage() {
> >>>>>>>>>    PageableListView<News> news =
> >>>>>>>>>    new PageableListView<News>("list", new NewsModel(), 15){
> >>>>>>>>>
> >>>>>>>>>        @Override
> >>>>>>>>>        protected void populateItem(final ListItem<News> item) {
> >>>>>>>>>            ourLogger.debug("Getting item value
> >>>>>>>>> "+item.getModelObject().getTitle());
> >>>>>>>>>
> >>>>>>>>>            News news = item.getModelObject();
> >>>>>>>>>                          item.add(new Label("date", new
> >>>>>>>>> Model(news.getDate())));
> >>>>>>>>>                          Link<News> l = new Link<News>("edit"){
> >>>>>>>>>
> >>>>>>>>>                @Override
> >>>>>>>>>                public void onClick() {
> >>>>>>>>>                    setResponsePage(new
> >>>>>>>>> NewsPage(item.getModelObject()));
> >>>>>>>>>                                      }
> >>>>>>>>> };
> >>>>>>>>>
> >>>>>>>>>            item.add(l);
> >>>>>>>>>            l.add(new Label("title", news.getTitle()));
> >>>>>>>>>
> >>>>>>>>>            item.add(new Link<News>("delete", new Model()){
> >>>>>>>>>
> >>>>>>>>>                @Override
> >>>>>>>>>                public void onClick() {
> >>>>>>>>>                    // TODO : check the refresh issue
> >>>>>>>>>                    getNewsDao().delete(item.getModelObject());
> >>>>>>>>>                    ourLogger.debug("News deleted");
> >>>>>>>>>                                      }
> >>>>>>>>>                              });
> >>>>>>>>>                      }
> >>>>>>>>>
> >>>>>>>>>              };
> >>>>>>>>>
> >>>>>>>>>    add(news);
> >>>>>>>>>    add(new OrPagingNavigator("navigator", news));
> >>>>>>>>>          add(new BookmarkablePageLink<Void>("add",
> NewsPage.class));
> >>>>>>>>>
> >>>>>>>>>      }
> >>>>>>>>>
> >>>>>>>>>  /**
> >>>>>>>>>  * Model for the news List to load the news from the db each time
> >>>>>>>>>  *
> >>>>>>>>>  */
> >>>>>>>>>  public class NewsModel extends
> LoadableDetachableModel<List<News>>
> >>>>>>>>> {
> >>>>>>>>>
> >>>>>>>>>    @Override
> >>>>>>>>>    protected List<News> load() {
> >>>>>>>>>        ourLogger.debug("Loading all news");
> >>>>>>>>>        return new NewsDao().load();
> >>>>>>>>>    }
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>  }
> >>>>>>>>>  }
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> Jeremy Thomerson a écrit :
> >>>>>>>>>
> >>>>>>>>>  You're probably not using models correctly - specifically for
> your
> >>>>>>>>> list
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> view.  You could post some code, but make sure that you're
> >>>>>>>>>> reloading
> >>>>>>>>>> the
> >>>>>>>>>> data for the list view after the onClick is called and the item
> is
> >>>>>>>>>> deleted.
> >>>>>>>>>>
> >>>>>>>>>> --
> >>>>>>>>>> Jeremy Thomerson
> >>>>>>>>>> http://www.wickettraining.com
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> On Tue, Jan 26, 2010 at 8:37 AM, Stéphane Jeanjean <
> >>>>>>>>>> stephane.jeanj...@softeam.com> wrote:
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>> Hello,
> >>>>>>>>>>>
> >>>>>>>>>>> My page displays a list of items, for each of them, an icon is
> >>>>>>>>>>> available
> >>>>>>>>>>> to
> >>>>>>>>>>> delete it. The action is managed in a Link.onClick() method.
> >>>>>>>>>>> When I click on the link, the page is refreshed but the item is
> >>>>>>>>>>> always
> >>>>>>>>>>> in
> >>>>>>>>>>> my list, I have to do refresh again manually the page to have a
> >>>>>>>>>>> list
> >>>>>>>>>>> wihtout
> >>>>>>>>>>> this item.
> >>>>>>>>>>>
> >>>>>>>>>>> In the logs, it seems that the deletion in the onClick() method
> is
> >>>>>>>>>>> called
> >>>>>>>>>>> after the load of the page :(
> >>>>>>>>>>>
> >>>>>>>>>>> Somebody has an idea to avoid this manual refresh ?
> >>>>>>>>>>>
> >>>>>>>>>>> Thanks,
> >>>>>>>>>>>
> >>>>>>>>>>> Stéphane
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> ---------------------------------------------------------------------
> >>>>>>>>>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >>>>>>>>>>> For additional commands, e-mail: users-h...@wicket.apache.org
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> ---------------------------------------------------------------------
> >>>>>>>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >>>>>>>>> For additional commands, e-mail: users-h...@wicket.apache.org
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> ---------------------------------------------------------------------
> >>>>>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >>>>>>> For additional commands, e-mail: users-h...@wicket.apache.org
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>> --
> >>>>>> Pedro Henrique Oliveira dos Santos
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >>>> For additional commands, e-mail: users-h...@wicket.apache.org
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >> For additional commands, e-mail: users-h...@wicket.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to