Hello,

Newbie wicket user, but liking it so far :)  Using 1.3.4

I've been trying to get a prototype going which will display a repeating
view and regularly update a list of data via Ajax.

My constructor for my component (which extends Panel) looks like this.
======================================
    public UpcomingRacesComponent(String id) {
        super(id);

        RepeatingView upcomingRacesRepeatingView = new
RepeatingView("upcomingRacesRepeater");
        this.add(upcomingRacesRepeatingView);

        String[] races = getRandomlyOrderedRaces();
        int index = 0;
        for (String race : races) {
            WebMarkupContainer item = new
WebMarkupContainer(upcomingRacesRepeatingView
                    .newChildId());
            upcomingRacesRepeatingView.add(item);
            item.add(new Label("raceLabel", race));
            index++;
        }
    }
======================================


the html for this looks like
======================================
<wicket:panel>
    <div wicket:id="upcomingRacesRepeater">
        <div wicket:id="raceLabel">
            [ race ]
        </div>
    </div>
</wicket:panel>
======================================


the code for the page that holds the component is
======================================
    public IndexPage() {
        final UpcomingRacesComponent upcomingRacesComponent =
            new UpcomingRacesComponent("upcomingRacesComponent");
        upcomingRacesComponent.setOutputMarkupId(true);
        upcomingRacesComponent.add(new
AjaxSelfUpdatingTimerBehavior(Duration.seconds(3)));
        this.add(upcomingRacesComponent);
    }
======================================


and the html within the page
======================================
        <div wicket:id="upcomingRacesComponent" class="upcomingRaces">
            [ Upcoming races component ]
        </div>
======================================


Through the Wicket debugger, I can see the request going to the server, but
the same data is always returned (i'm randomizing the order for testing, so
it should be changing). I also tried wrapping the component withing a
WebMarkupContainer (as described in the Wicket In Action). but that didn't
work either. It's pretty obvious why it isn't working since the constructor
is only being called once and hence getRandomlyOrderedRaces is only called
once, but I've been trying various different things and I can't seem to find
where to hook in getRandomlyOrderedRaces so that it is called upon each of
the AJAX calls.

Any help appreciated, this is probably a really dumb question

Thanks
Daryl

Reply via email to