Announcement Announcement Module
Collapse
No announcement yet.
<form:select> and Java enum Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • <form:select> and Java enum

    Hi all,

    I have problem by binding the enum in <form:select>.

    My enum looks as follow:
    Code:
    	enum FizzyDrink{
    		pepsi("Pepsi"), coke("Coca Cola"), schweppes("Schweppes");
    		
    		private String name;
    		
    		FizzyDrink(String name){
    			this.name = name;
    		}
    		
    		public String getName(){
    			return name;
    		}
    My Form-class looks as follow:
    Code:
    class MyForm{
    ...
    	public List<String> getDrinkList(){
    		List<String> drinkList = new ArrayList<String>();
    		
    		for(FizzyDrink f : FizzyDrink.values()){
    			drinkList.add(f.getName());
    		}
    		return drinkList;
    	}
    ...
    }
    And the code in the .jsp looks as follow:
    Code:
    ...
         <form:select path="drink" items="${applicationForm.drinkList}" itemValue="name" />
    ...
    But I got exceptions that the 'name' cannot be mapped.

    I don't use MVC but Spring Web Flow. Someone has idea?
Working...
X