Grails显示Flash消息中已删除邮件的数量

时间:2013-01-07 12:49:40

标签: grails

  

可能重复:
  Grails Editing Flash Delete Message

您好,
我是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])
        }
    }
}

0 个答案:

没有答案