View Javadoc

1   package nl.gridshore.samples.raffle.web.wicket.raffle;
2   
3   import nl.gridshore.samples.raffle.domain.Participant;
4   import nl.gridshore.samples.raffle.domain.Raffle;
5   import nl.gridshore.samples.raffle.web.wicket.BasePage;
6   import org.apache.wicket.PageParameters;
7   import org.apache.wicket.markup.html.basic.Label;
8   import org.apache.wicket.markup.html.form.Form;
9   import org.apache.wicket.markup.html.link.Link;
10  import org.apache.wicket.markup.html.list.ListItem;
11  import org.apache.wicket.markup.html.list.ListView;
12  
13  /**
14   * Created by IntelliJ IDEA.
15   * User: jettro
16   * Date: Nov 27, 2007
17   * Time: 8:51:12 PM
18   * Remove the raffle from the from the storage
19   */
20  public class DeleteRafflePage extends BasePage {
21      public DeleteRafflePage(PageParameters pageParams) {
22          super();
23          add(new Label("page-title-label", "View raffle"));
24  
25          final Raffle raffle = raffleService.giveRaffleById(pageParams.getLong(RaffleConstants.PARAM_RAFFLE_ID));
26          add(new Label("title-label", "Raffle title"));
27          add(new Label("title", raffle.getTitle()));
28          add(new Label("description-label", "Raffle description"));
29          add(new Label("description", raffle.getDescription()));
30          add(new Label("participant-name-label", "Participant name"));
31          add(new ListView("participants", raffle.getParticipants()) {
32              protected void populateItem(ListItem item) {
33                  Participant participant = (Participant) item.getModelObject();
34                  item.add(new Label("name", participant.getName()));
35              }
36          });
37  
38          Form raffleForm = new Form("form");
39          raffleForm.add(new Link("cancelraffle") {
40              public void onClick() {
41                  setResponsePage(AllRafflesPage.class);
42              }
43          });
44          raffleForm.add(new Link("deleteraffle") {
45              public void onClick() {
46                  raffleService.removeRaffle(raffle);
47                  setResponsePage(AllRafflesPage.class);
48              }
49          });
50          add(raffleForm);
51      }
52  }