Grails Editing Flash Delete Message

前端 未结 3 1746
刺人心
刺人心 2021-01-17 06:05

Hi am new at Grails i have implemented a delete action that deleted messages in an inbox,, but now i want to change the flash message to display \"2 Messages deleted\" not

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-17 06:51

    You could do this:

        def device = MessagingDevice.findByPhoneNumber(params.phoneNumber)
    
        // invoke deleteFromDevice on domain object, which returns number of objects deleted
        def count = messageInstance.deleteFromDevice(device)
        if (count) {
            flash.message = message(code: 'default.deleted.message', args: [message(code: 'message.deleted.label', default: '{0} Messages deleted'), count])
            redirect(action: "phone", params:[phoneNumber:params.phoneNumber])
        }
    

    and in your messages.properties

    message.deleted.label={0} deleted
    

提交回复
热议问题