Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p><em>I'm looking for more elegant solution. Because JSF wants it private + getters and setters, and the other JAVA class wants it private STATIC + get, sets. So I sometimes need to use two booleans for one thing and it makes a bit of mess...</em></p> </blockquote> <p>Just let the JSF bean getter delegate. E.g.</p> <pre><code>public boolean isProduction() { return Settings.PRODUCTION; } </code></pre> <p>This way you end up with only one variable containing the value, namely <code>Settings.PRODUCTION</code>. You can even decouple it from the request/view scoped bean and wrap it in an application scoped managed bean. Even more, if you let it extend <code>Map</code> and put the values upon construction, then you'll be able to use something like <code>disabled="#{settings['PRODUCTION']}"</code>.</p> <p>E.g.</p> <pre><code>@ManagedBean(name="settings", eager=true) @ApplicationScoped public class SettingsManager extends HashMap&lt;String, Object&gt; { public SettingsManager() { put("PRODUCTION", Settings.PRODUCTION); put("DEBUG", Settings.DEBUG); put("HOSTNAME", Settings.HOSTNAME); // ... } } </code></pre> <p>If you're still on JSF 1.x, remove those annotations and map it as follows in <code>faces-config.xml</code>.</p> <pre><code>&lt;managed-bean&gt; &lt;managed-bean-name&gt;settings&lt;/managed-bean-name&gt; &lt;managed-bean-class&gt;com.example.SettingsManager&lt;/managed-bean-class&gt; &lt;managed-bean-scope&gt;application&lt;/managed-bean-scope&gt; &lt;/managed-bean&gt; </code></pre>
    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