翻译JAVA

来源:百度知道 编辑:UC知道 时间:2024/06/23 21:54:02
Referencing a Java Enum Type
As of version 1.2 of JavaServer Faces technology, a managed bean property can also be a Java Enum type (see http://java.sun.com/javase/6/docs/api/java/lang/Enum.html). In this case, the value element of the managed-property element must be a String that matches one of the String constants of the Enum. In other words, the String must be one of the valid values that can be returned if you were to call valueOf(Class, String) on enum, where Class is the Enum class and String is the contents of the value subelement. For example, suppose the managed bean property is the following:
public enum Suit { Hearts, Spades, Diamonds, Clubs}
...
public Suit getSuit() { ... return Suit.Hearts; }Assuming that you want to configure this property in the application configuration file, the corresponding managed-property element would look like thi

引用一个Java枚举类型

截至1.2版本的JavaServer界面技术,有管理的bean属性也可以一个Java枚举类型(见http://java.sun.com/javase/6/docs/api/java/lang/Enum.html ) 。在这种情况下,价值要素,管理的财产内容必须是一个字符串匹配一个字符串常量的枚举。换言之,字符串必须是有效的价值观,可以返回如果你是要求valueOf (类,弦乐)的枚举,而类是枚举类和字符串的内容是价值子元素。例如,假设有管理的bean属性如下:
公共枚举战士(心,黑桃,钻石,俱乐部)
...

公共服getSuit ( ) ( ...返回Suit.Hearts ; )假如您要设定这个属性在应用程序配置文件,相应的管理知识产权的内容将如下所示:
<managed-property>

<property-name>战士“ /物业名称”

<值>心“ /价值”

“ /管理的财产”当系统遇到这个属性,它遍历每个成员的枚举,并呼吁toString ( )的每一个成员,直到它找到一个完全平等的价值的价值元素。

引用一个初始化参数

另一个强大的功能的管理创造豆设施的能力范围内隐的物体从一个管理bean属性。