View Javadoc

1   package nl.gridshore.samples.raffle.web.wicket.raffle;
2   
3   import nl.gridshore.samples.raffle.business.RaffleService;
4   import nl.gridshore.samples.raffle.domain.Participant;
5   import nl.gridshore.samples.raffle.domain.Prize;
6   import nl.gridshore.samples.raffle.domain.Raffle;
7   import nl.gridshore.samples.raffle.web.wicket.BasePage;
8   import org.apache.wicket.PageParameters;
9   import org.apache.wicket.markup.html.basic.Label;
10  import org.apache.wicket.markup.html.link.Link;
11  import org.apache.wicket.markup.html.list.ListItem;
12  import org.apache.wicket.markup.html.list.ListView;
13  import org.apache.wicket.spring.injection.annot.SpringBean;
14  
15  /**
16   * Created by IntelliJ IDEA.
17   * User: jettro
18   * Date: Nov 23, 2007
19   * Time: 9:31:28 PM
20   * Page showing a specific Raffle with all the participants and winners
21   */
22  public class ViewRafflePage extends BasePage {
23      @SpringBean
24      RaffleService raffleService;
25  
26      public ViewRafflePage(final PageParameters pageParams) {
27          add(new Label("page-title-label", "View raffle"));
28  
29          Raffle raffle = raffleService.giveRaffleById(pageParams.getLong(RaffleConstants.PARAM_RAFFLE_ID));
30          add(new Label("title-label", "Raffle title"));
31          add(new Label("title", raffle.getTitle()));
32          add(new Label("description-label", "Raffle description"));
33          add(new Label("description", raffle.getDescription()));
34          add(new Label("participant-name-label", "Participant name"));
35          add(new ListView("participants", raffle.getParticipants()) {
36              protected void populateItem(ListItem item) {
37                  Participant participant = (Participant) item.getModelObject();
38                  item.add(new Label("name", participant.getName()));
39              }
40          });
41          add(new Label("prize-title-label", "Prize title"));
42          add(new Label("prize-description-label", "Prize description"));
43          add(new ListView("prizes", raffle.getPrizes()) {
44              protected void populateItem(ListItem item) {
45                  Prize prize = (Prize) item.getModelObject();
46                  item.add(new Label("prize-title-value", prize.getTitle()));
47                  item.add(new Label("prize-description-value", prize.getDescription()));
48              }
49          });
50          add(new Link("back") {
51              public void onClick() {
52                  setResponsePage(AllRafflesPage.class);
53              }
54          });
55      }
56  }