struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Fisher <Matthew.Fis...@metcash.com>
Subject JSTL and enums
Date Mon, 05 Apr 2004 05:28:36 GMT
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


Mime
View raw message