Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'd refactor your code first:</p> <pre><code>public enum SearchLocationTypes { REGISTRATION("rg"), WORKPLACE("wp"); private String abbr; SearchLocationTypes(String abbr) { this.abbr = abbr; } @Override public String toString() { return abbr; } public static SearchLocationTypes fromString(String from) { for (SearchLocationTypes locType : SearchLocationTypes.values()) { if (locType.abbr.equals(from)) { return locType; } } throw new IllegalArgumentException(); } } </code></pre> <p>and <code>Formatter</code> (and <code>Converter</code> same as print method):</p> <pre><code>public class SearchLocationTypesFormatter implements Formatter&lt;SearchLocationTypes&gt; { @Override public String print(SearchLocationTypes type, Locale locale) { return type == null ? "" : type.toString(); } @Override public SearchLocationTypes parse(String strType, Locale locale) throws ParseException { return SearchLocationTypes.fromString(strType); } } </code></pre> <p>Now you can use it in jsp with <code>form:radiobuttons</code> or <code>form:options</code>:</p> <pre><code>&lt;form:select path="locType"&gt; &lt;form:options /&gt; &lt;/form:select&gt; </code></pre> <p><em>where by default the form value is the enum's name() and the form label is the enum's toString()</em> (from <a href="https://jira.springsource.org/browse/SPR-3389" rel="nofollow">https://jira.springsource.org/browse/SPR-3389</a>).</p> <p>I can't check this out, but try <code>&lt;s:eval expression="form.locType"&gt;</code> now.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload