domain中枚举类型的应用

14 views
Skip to first unread message

Alex wang

unread,
Dec 9, 2009, 10:11:34 PM12/9/09
to grail...@googlegroups.com
对于常见的状态,比如“未审核、已审核”等不同的状态,我们一般用数字表示,也有用枚举类型来表示的,大家在实际使用中哪种方式比较多?


---------------------------------------------
Alex wang
website:颠覆软件 http://www.foxlog.org
twitter: http://twitter.com/foxlog
douban: http://www.douban.com/people/foxlog
gmail: idea.wang[at]gmail.com

wang xin

unread,
Dec 9, 2009, 10:15:30 PM12/9/09
to grail...@googlegroups.com
我一般用枚举类型。好处是,可以有清楚的分类,而且也不容易搞混。

2009/12/10 Alex wang <idea...@gmail.com>



--
Xin Wang
xinw...@gmail.com

Ford Guo

unread,
Dec 9, 2009, 10:17:15 PM12/9/09
to grail...@googlegroups.com
enum :),可支持国际化 :)
Ford Guo


2009/12/10 Alex wang <idea...@gmail.com>

clt.phoenix

unread,
Dec 10, 2009, 2:31:43 AM12/10/09
to grail...@googlegroups.com
enum 怎么支持国际化??
--
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/

Ford Guo

unread,
Dec 10, 2009, 2:36:54 AM12/10/09
to grail...@googlegroups.com
跟inList方式是一样的,参考 http://grails.org/I18n+Templates+Plugin
Ford Guo


2009/12/10 clt.phoenix <clt.p...@gmail.com>

Liu Chao

unread,
Dec 10, 2009, 3:24:05 AM12/10/09
to grail...@googlegroups.com
在页面中怎么用?

2009/12/10 Ford Guo <agil...@gmail.com>



--
My Grails Powered Website:
http://team.goal98.com

Grails Melody Plugin:
https://svn.codehaus.org/grails-plugins/grails-grails-melody

Grails Templar Poject:
http://code.google.com/p/grails-templar/

Ford Guo

unread,
Dec 10, 2009, 3:36:37 AM12/10/09
to grail...@googlegroups.com
<g:message code="domainInstance.enunField.enumValue"/>

Ford Guo


2009/12/10 Liu Chao <liuc...@gmail.com>

Liu Chao

unread,
Dec 10, 2009, 3:45:01 AM12/10/09
to grail...@googlegroups.com
这跟用不用enum有什么关系呢?

2009/12/10 Ford Guo <agil...@gmail.com>

Ford Guo

unread,
Dec 10, 2009, 3:46:06 AM12/10/09
to grail...@googlegroups.com
用了enum更多的是在处理业务逻辑的时候方便.

clt.phoenix

unread,
Dec 10, 2009, 3:50:48 AM12/10/09
to grail...@googlegroups.com
觉得应该将 message 标签 简化为 msg , message名字太长了。

Liu Chao

unread,
Dec 10, 2009, 3:50:43 AM12/10/09
to grail...@googlegroups.com
。。。有IDE你还怕这个

2009/12/10 clt.phoenix <clt.p...@gmail.com>

clt.phoenix

unread,
Dec 10, 2009, 3:59:28 AM12/10/09
to grail...@googlegroups.com
机器老, 内存小, 没用 IDE................

Michael

unread,
Dec 14, 2009, 11:32:42 PM12/14/09
to grail...@googlegroups.com
在message_ZH.properties 中定义后, 直接在domain, controller, view中就可以使用啦
比如说:
message_ZH定义如下
a.type1=国企
a.type2=外企
在domain中的constaints可以写
property(inList[message(code:'a.type1'),message(code:'a.type2')])
 
貌似我是这么用的,但是可以参考grails的example, 那个例子有用到
           

2009/12/10 clt.phoenix <clt.p...@gmail.com>
--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛“Grails联盟-GrailsUnion”论坛。
 要在此论坛发帖,请发电子邮件到 grail...@googlegroups.com
 要退订此论坛,请发邮件至 grailsunion...@googlegroups.com
 更多选项,请通过 http://groups.google.com/group/grailsunion?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---


Alex wang

unread,
Dec 29, 2009, 5:04:59 AM12/29/09
to Grails联盟-GrailsUnion
我在用这个 property(inList[message(code:'a.type1'),message
(code:'a.type2')]) ,貌似在domain中说没有message这个方法错误,怎么回事?

code如下:
businessType(inList:[message
(code:'businessChance.businessType.NONE'),message
(code:'businessChance.businessType.NEW'),message
(code:'businessChance.businessType.OLD')])

On Dec 15, 12:32 pm, Michael <yaoqiangshm...@gmail.com> wrote:
> 在message_ZH.properties 中定义后, 直接在domain, controller, view中就可以使用啦
> 比如说:
> message_ZH定义如下
> a.type1=国企
> a.type2=外企
> 在domain中的constaints可以写
> property(inList[message(code:'a.type1'),message(code:'a.type2')])
>
> 貌似我是这么用的,但是可以参考grails的example, 那个例子有用到
>

> 2009/12/10 clt.phoenix <clt.phoe...@gmail.com>
>
>
>
> > enum 怎么支持国际化??


>
> > 在 Thu, 10 Dec 2009 11:17:15 +0800,Ford Guo <agile....@gmail.com> 写道:
>
> > > enum :),可支持国际化 :)
> > > Ford Guo
>

> > > 2009/12/10 Alex wang <idea.w...@gmail.com>


>
> > >> 对于常见的状态,比如"未审核、已审核"等不同的状态,我们一般用数字表示,也有用枚举类型来表示的,大家在实际使用中哪种方式比较多?
>
> > >> ---------------------------------------------
> > >> Alex wang

> > >> website:颠覆软件http://www.foxlog.org


> > >> twitter:http://twitter.com/foxlog
> > >> douban:http://www.douban.com/people/foxlog
> > >> gmail: idea.wang[at]gmail.com
>
> > --
> > 使用 Opera 革命性的电子邮件客户程序:http://www.opera.com/mail/
> > --~--~---------~--~----~------------~-------~--~----~
> > 您收到此信息是由于您订阅了 Google 论坛"Grails联盟-GrailsUnion"论坛。
> > 要在此论坛发帖,请发电子邮件到 grail...@googlegroups.com

> > 要退订此论坛,请发邮件至 grailsunion...@googlegroups.com<grailsunion%2Bunsubscribe@googlegr oups.com>
> > 更多选项,请通过http://groups.google.com/group/grailsunion?hl=zh-CN访问该论坛
> > -~----------~----~----~----~------~----~------~--~---

沈添

unread,
Jan 1, 2010, 3:37:05 AM1/1/10
to grail...@googlegroups.com
grails1.1 之后的版本,把enum类型都是以String类型保存到数据库. 大家知道这是基于什么考虑的吗?
另外上面大家讨论的国际化还是看不大懂.能否总结出一个完整的解释啊?

参考:

1) Enum types are now mapped using their String value rather than the ordinal value. You can revert to the old behavior by changing your mapping as follows:

static mapping = {
      someEnum enumType:"ordinal"
}

2) Bidirectional one-to-one associations are now mapped with a single column on the owning side and a foreign key reference. You shouldn't need to change anything, however you may want to drop the column on the inverse side as it contains duplicate data.





2009/12/29 Alex wang <idea...@gmail.com>
> > -~----------~----~----~----~------~----~------~--~---

--

您收到此邮件是因为您订阅了 Google 网上论坛的“Grails联盟-GrailsUnion”论坛。
要向此网上论坛发帖,请发送电子邮件至 grail...@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 grailsunion...@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/grailsunion?hl=zh-CN 访问此网上论坛。



Michael

unread,
Jan 7, 2010, 8:24:38 PM1/7/10
to grail...@googlegroups.com
不好意思 王哥, 我记错了.
在domain中我就是写的中文, 在view里我用的国际化.

2009/12/29 Alex wang <idea...@gmail.com>
--

您收到此邮件是因为您订阅了 Google 网上论坛的“Grails联盟-GrailsUnion”论坛。
要向此网上论坛发帖,请发送电子邮件至 grail...@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 grailsunion...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages