You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matthew Fisher <Ma...@metcash.com> on 2004/04/05 07:28:36 UTC

JSTL and enums

Hi everyone,

I have been given the enjoyable job of converting our jsp files from
scriplet code to jstl and I have come accross this problem. I need to
convert the following line:
<%=TransactionType.newLine.getName()%>

Naturally TransactionType was already imported, so I've set the enum list to
the pageContext with the following:
List transactionTypes = TransactionType.getEnumList();
pageContext.setAttribute("transactionTypes",  transactionTypes);

but I'm not sure where to go from here.

Below is the class TransactionType for a clearer picture. Any help would be
greatly appreciated.

Matthew

********** ********** ********** ********** ********** 
public class TransactionType extends ValuedEnum {
	public static final TransactionType newLine = new
TransactionType("New Line", 1);
	public static final TransactionType packChange = new
TransactionType("Pack Change", 2);
	public static final TransactionType priceChange = new
TransactionType("Price Change", 3);

	private TransactionType(String name, int value) {
		super(name, value);
	}

	public static TransactionType getEnum(String name) {
		return (TransactionType) getEnum(TransactionType.class,
name);
	}

	public static TransactionType getEnum(int value) {
		return (TransactionType) getEnum(TransactionType.class,
value);
	}

	public static Map getEnumMap() {
		return getEnumMap(TransactionType.class);
	}

	public static List getEnumList() {
		return getEnumList(TransactionType.class);
	}

	public static Iterator iterator() {
		return iterator(TransactionType.class);
	}

}
********** ********** ********** ********** ********** 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org