コード例 #1
0
  public void savePaintingAction(IRequestCycle cycle) {
    Painting painting = getPainting();
    Artist artist = getArtist();

    if (!assertNotNull(painting.getPaintingTitle())) {
      appendHtmlToErrorMessage("You must provide a painting title.");
      return;
    }

    DataContext ctxt = getVisitDataContext();

    // painting was created earlier, but before we can
    // start working with its relationships, and ultimately
    // save it to DB, it must be regsitered with DataContext
    ctxt.registerNewObject(painting);

    // establish relationship with artist via a simple method call
    // an equivalent of the line below would be "
    artist.addToPaintingArray(painting);

    // commit to the database
    ctxt.commitChanges();

    BrowseArtistsPage nextPage = (BrowseArtistsPage) cycle.getPage("BrowseArtistsPage");

    cycle.activate(nextPage);
  }
コード例 #2
0
 public void pageBeginRender(PageEvent event) {
   Painting painting = new Painting();
   painting.setEstimatedPrice(new BigDecimal(0));
   setPainting(painting);
 }