i have an enum in my data-class as follows
public enum 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;
}
};
The Proc_Stat refers to a Number field in a DataBase table and i need to show a column on the page where it shows the corresponding String of the numeric proc_stat for each row.
This is how i render any other field of the same data-class on the xhtml page:
id=”dataTable” name=”dataTable” var=”data”
How do i give output value for enum type?
do i give like this : value=”#{data.procstat.toString()}” ??
I think you need to create method in one of your managed bean that does the same as
getProcStatmethod. Something like:In xhtml: