-1

可能重复:
Grails 编辑 Flash 删除消息

嗨,
我是 Grails 的新手,我已经实现了删除收件箱中的消息的删除操作,但现在我想更改 flash 消息以显示2 条消息已删除而不是4 号消息已删除,如果删除多条消息,则 5 号消息已删除。请协助,以下是我的删除操作

def delete() {

    def messageInstance = Message.get(params.id)

    // render error if no message found
    if (!messageInstance) {
        flash.message = message(code: 'default.not.found.message', args: [message(code: 'message.label', default: 'Message'), params.id])
        redirect(action: "phone")
    } else {
        // get the device that we are deleting from
        //specify phoneNumber so as to delete the device by phoneNumber
        def device = MessagingDevice.findByPhoneNumber(params.phoneNumber)

        // invoke deleteFromDevice on domain object, which returns true if successful
        if (messageInstance.deleteFromDevice(device)) {
            flash.message = message(code: 'default.deleted.message', args: [message(code: 'message.label', default: 'Message'), params.id])
            redirect(action: "phone", params:[phoneNumber:params.phoneNumber])
        }
    }
}
4

0 回答 0