There are several ways depending on how and where you'd like to maintain the mapping between status codes and associated descriptions.
Hardcoded in view.
<h:outputText value="New" rendered="#{t.part_status == 1}" /> <h:outputText value="Rejected" rendered="#{t.part_status == 2}" /> <h:outputText value="Cancelled" rendered="#{t.part_status == 5}" />
Hardcoded in a map.
@ManagedBean @ApplicationScoped public class Data { private static final Map<Long, String> STATUSES = createStatuses(); private static Map<Long, String> createStatuses() { Map<Long, String> statuses = new HashMap<Long, String>(); statuses.put(1L, "New"); statuses.put(2L, "Rejected"); statuses.put(5L, "Cancelled"); return Collections.unmodifiableMap(statuses); } public Map<Long, String> getStatuses() { return STATUSES; } }
with
<h:outputText value="#{data.statuses[t.part_status]}" />
Definied in a loclaized resource bundle file.
status.1 = New status.2 = Rejected status.5 = Cancelled
with
<f:loadBundle basename="com.example.i18n.text" var="text" /> ... <c:set var="statusKey" value="status.#{t.part_status}" /> <h:outputText value="#{text[statusKey]}" />
Definied in an enum.
public enum Status { New(1), Rejected(2), Cancelled(5); private int code; private Status(int code) { this.code = code; } public static Status of(int code) { for (Status status : values()) { if (status.code == code) { return status; } } throw new IllegalArgumentException(); } public int getCode() { return code; } }
and during populating the model
t.setPart_status(Status.of(statusCode));
and then just in the view
<h:outputText value="#{t.part_status}" />
A combination can also. E.g. i18n label in enum.
Unrelated to the concrete problem, I'd work on your Java naming conventions. part_status
is not a valid property name. It should be partStatus
.