2015-11-30 3 views
0

Я озадачен, почему страница редактирования editdonation не отображается, поскольку don.save() терпит неудачу, потому что в домене, если customDonationMin больше, чем customDonationMax, тогда происходит ошибка проверки. Для вашей справки я вставил ниже пользовательского валидатора.Даже если домен не может сохранить код страницы просмотра рендеринга, не загружается?

customDonationMax nullable: true, min: BigDecimal.ZERO, validator: { BigDecimal max, EventDonation obj -> 
    if (max != null && obj.customDonationMin > max){ 
     return 'donation.min.max.error' 
    } 
} 

Ниже приведен обновленный метод обработки. В Params я намеренно установить customDonationMin больше customDonationMax провалить don.save()

def updatedonation(Long id){ 
    def ev = CompositeEvent.get(id) 

    myAclService.hasWritePermission(ev.id, CompositeEvent) 

    //Make sure the question that we are editing exists 
    List<EventDonationCompositeEvent> donation_comp_event = EventDonationCompositeEvent.createCriteria().list(){ 
     eq('event', ev); 
    } 

    def don = donation_comp_event[0].donation 

    List<String> whiteList = ['title', 'body', 'customDonationMin', 'customDonationMax'] 
    bindData(don, params, ['include': whiteList]) 

    //Now we save the donation 

    if (!don.save()) { 
     don.errors.each {  
      //here this render doesnt work instead the the below code executes redirect(controller: "compositeEvent", action: "home", id: id) 
      render(view: "editdonation", model: [id:id, donation:don]) 
      return 
     } 
    } 

    flash.message = "Donation setup successful!!" 
    redirect(controller: "compositeEvent", action: "home", id: id) 
    return 
} 
+0

Несвязанный с вашей проблемой, но вам не нужны ключевые слова 'return' после' render' или 'redirect'. – tylerwal

ответ

0

Я заметил, что когда я изменить приведенный выше код следующим образом, то проблема решена.

if (!don.save()) { 

       //here this render doesnt work instead the the below code executes redirect(controller: "compositeEvent", action: "home", id: id) 

       render(view: "editdonation", model: [id:id, donation:don]) 
       return 

     } 

 Смежные вопросы

  • Нет связанных вопросов^_^