Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is indeed not going to work. Enum properties are initialized only once, applicationwide, while i18n is essentially supposed to be resolved on a per-request basis.</p> <p>You need to redesign your enum as such that only the label keys are hold instead of the resolved localized values.</p> <pre><code>TRUCK("tv.moc.truck", "TRUCK"), AIRFREIGHT("tv.moc.airfreight", "AIRFREIGHT"), TRAIN("tv.moc.train", "TRAIN"), SEAFREIGHT("tv.moc.seafreight", "SEAFREIGHT"), BARGE("tv.moc.barge", "BARGE"); </code></pre> <p>And then provide the enum values as follows in an application scoped bean:</p> <pre><code>@ManagedBean @ApplicationScoped public class Data { public Transportmittel[] getTransportmittels() { return Transportmittel.values(); } } </code></pre> <p>And then reference it in <code>&lt;f:selectItems&gt;</code> as follows (look, no need for <code>SelectItem</code> boilerplate):</p> <pre class="lang-html prettyprint-override"><code>&lt;f:selectItems value="#{data.transportmittels}" var="transportmittel" itemValue="#{transportmittel}" itemLabel="#{bundle[transportmittel.ausgabe]}" /&gt; </code></pre> <p>Or, if you happen to use JSF utility library <a href="http://omnifaces.org" rel="nofollow noreferrer">OmniFaces</a> already, as currently indicated in your user profile, then you could also bypass the whole application scoped <code>Data</code> bean and <a href="http://showcase.omnifaces.org/taghandlers/importConstants" rel="nofollow noreferrer">import</a> it straight in the EL scope as follows:</p> <pre class="lang-html prettyprint-override"><code>&lt;o:importConstants type="com.example.Transportmittels" /&gt; &lt;!-- can be declared in a master template --&gt; ... &lt;f:selectItems value="#{Transportmittels}" var="transportmittel" itemValue="#{transportmittel}" itemLabel="#{bundle[transportmittel.ausgabe]}" /&gt; </code></pre> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/4375578/jsf-best-way-to-enum-internationalization-i18n/4377192#4377192">Localizing enum values in resource bundle</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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