/**
  * Create request mode means that the user requests the application to create a new persistent
  * bean with supplied information.. In create request mode, new data is stored in persistent
  * storage. The request should provide data for all properties of the {@link PersistentBean},
  * except the {@link PersistentBean#getId()}. If the create operation succeeds, the data is simply
  * displayed in a non-editable way. If the create operation fails, the data is displayed in an
  * HTML form, so that it can be corrected.
  *
  * @pre form != null;
  * @pre form.getPersistentBean() != null;
  * @pre request != null;
  */
 private void templateCreate(final CrudDynaActionForm form, final HttpServletRequest request)
     throws CompoundPropertyException, TechnicalException {
   assert form != null;
   assert request != null;
   if (LOG.isDebugEnabled()) {
     LOG.debug("create action ..."); // $NON-NLS-1$
   }
   form.initBean();
   /*
    * BeanInstantiationException; this means that the app is wrongly
    * configured; this will generate a general error page.
    */
   assert form.getPersistentBean() != null;
   assert form.getPersistentBean().getId() == null;
   form.setViewModeDeleted(false);
   AsynchronousCRUD asyncCRUD = createAsynchronousCRUD(request);
   try {
     asyncCRUD.startTransaction();
     form.formToBean(asyncCRUD); // PropertyException, inside transaction
     form.getPersistentBean().setId(null);
     asyncCRUD.createPersistentBean(form.getPersistentBean());
     // PropertyException
     form.beanToId();
     form.beanToForm(asyncCRUD); // inside transaction
     asyncCRUD.commitTransaction(form.getPersistentBean());
     form.setViewModeEdit(false);
     CreatedEvent pbnEvent = new CreatedEvent(form.getPersistentBean());
     fireCommittedEvent(pbnEvent);
     assert !form.isViewModeNew();
     assert !form.isViewModeDeleted();
     if (LOG.isDebugEnabled()) {
       LOG.debug("create action succeeded"); // $NON-NLS-1$
     }
   } catch (CompoundPropertyException cpExc) {
     form.beanToForm(asyncCRUD);
     asyncCRUD.cancelTransaction();
     form.setViewModeNew(true);
     assert form.isViewModeEdit();
     assert !form.isViewModeDeleted();
     throw cpExc;
   } finally {
     releaseAsynchronousCRUD(asyncCRUD);
   }
 }
 /**
  * New request mode means that the user requests the application to present a form with default
  * information, to be able to request the application to create a new object in the next step. In
  * new request mode, a new persistent bean is created with default data and displayed in an HTML
  * form, so that it can be edited. All the data that is already in this request is used to display
  * the new entity the first time.
  *
  * @throws BeanInstantiationException Could not create a new bean of the expected type.
  * @throws TechnicalException Could evaluate data for a technical reason
  * @throws CompoundPropertyException Some of the provided data is wrong.
  */
 private void templateNew(final CrudDynaActionForm form, final HttpServletRequest request)
     throws BeanInstantiationException, TechnicalException, CompoundPropertyException {
   if (LOG.isDebugEnabled()) {
     LOG.debug("new action ..."); // $NON-NLS-1$
   }
   form.initBean(); // bean contains programmatic defaults
   /*
    * BeanInstantiationException; this means that the app is wrongly
    * configured; this will generate a general error page.
    */
   assert form.getPersistentBean() != null;
   assert form.getPersistentBean().getId() == null;
   form.beanToId();
   AsynchronousCRUD asyncCRUD = createAsynchronousCRUD(request);
   CompoundPropertyException cpExcStore = null;
   try {
     // @todo (dvankeer): Why re-use the data?
     try {
       form.formToBean(asyncCRUD);
       /* get the data that is already in this request,
       overwriting programmatic defaults */
     } catch (CompoundPropertyException cpExc) {
       cpExcStore = cpExc;
       // remember this exception
     }
     // we are not doing this in a transaction, deliberately
     // @todo (jand): is this a good idea?
     form.beanToForm(asyncCRUD);
     // copy default data and data already set into the form
   } finally {
     releaseAsynchronousCRUD(asyncCRUD);
   }
   form.setViewModeNew(true);
   assert form.isViewModeEdit();
   assert !form.isViewModeDeleted();
   if (LOG.isDebugEnabled()) {
     LOG.debug("new action succeeded"); // $NON-NLS-1$
   }
   if (cpExcStore != null) {
     throw cpExcStore;
   }
 }