我的数据类中有一个枚举,如下所示
公共枚举 ProcStat {
NOT_READY ((byte)-1, "Not Ready For Processing"),
READY_FOR_PROCESSING ((byte)0, "Ready For Processing"),
BEING_PROCESSED ((byte)1, "Being Processed"),
PROCESSED_SUCCESSFULLY ((byte)2, "Processed Successfully"),
MSG_SUPPRESSED ((byte)98, "Msg suppressed before processing"),
PROCESSED_ERROR ((byte)99, "Processed With Error");
private final Byte statByte;
private final String statusDesc;
ProcStat(Byte statByte, String statusDesc)
{
this.statByte = statByte;
this.statusDesc = statusDesc;
}
@Override
public String toString()
{
return statusDesc;
}
protected static ProcStat getProcStat(Byte procStat)
{
if (READY_FOR_PROCESSING.statByte.equals(procStat))
{
return READY_FOR_PROCESSING;
}
else if (BEING_PROCESSED.statByte.equals(procStat))
{
return BEING_PROCESSED;
}
else if (PROCESSED_SUCCESSFULLY.statByte.equals(procStat))
{
return PROCESSED_SUCCESSFULLY;
}
else if (MSG_SUPPRESSED.statByte.equals(procStat))
{
return MSG_SUPPRESSED;
}
else if (PROCESSED_ERROR.statByte.equals(procStat))
{
return PROCESSED_ERROR;
}
else
{
return NOT_READY;
}
}
public Byte getStatByte()
{
return this.statByte;
}
};
Proc_Stat 指的是数据库表中的数字字段,我需要在页面上显示一列,其中显示每行的数字 proc_stat 的相应字符串。这就是我在 xhtml 页面上呈现相同数据类的任何其他字段的方式:
id="dataTable" name="dataTable" var="data"
如何为枚举类型提供输出值?我给这样的: value="#{data.procstat.toString()}" ?