title: Illegal Syntax for Set Operation: How to tell JSF I don't "want" a setter
body: <p>This question may be more of the type "conceptual" or "I don't understand JSF".</p>
  
  <p>My scenario:
  I have a JSF Page (<code>index.xhtml</code>) where I use a <code>p:accordionPanel</code> (but I don't think it matters what component it is). What I want to do is to set the <code>activeIndexes</code> of it.</p>
  
  <pre><code>&lt;p:accordionPanel multiple="true" activeIndex="#{myController.getActiveIndexesForSections('whatever')}"&gt;
  // bla bla...
  &lt;/p:accordionPanel&gt;
  </code></pre>
  
  <p>And the (simplified) method in the backing bean:</p>
  
  <pre><code>public String getActiveIndexesForSections(String holderName){
      String activeSections = "";
      for(Section s : sectionMap.get(holderName)){
          if (s.isActive())
          //add to the string
      }
      return activeSections;
  }
  </code></pre>
  
  <p>Now this works just fine on a normal page load.</p>
  
  <p>But if I click on a <code>p:commandButton</code> (with <code>ajax=false</code>) (or anything else which "sends" data back to the server I guess) - I get the following exception:</p>
  
  <pre><code>/WEB-INF/tags/normalTextSection.xhtml @8,112 activeIndex="#{myController.getActiveIndexesForSections(name)}": Illegal Syntax for Set Operation
  // bla..
  Caused by: javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation
  </code></pre>
  
  <p>After some googling / reading the error message I found that I need a <code>setter</code>.</p>
  
  <p>First of all: I don't want a setter - do I really need one or is there a way to tell JSF I don't want this "behavior".</p>
  
  <p>Second I realized that it's not that "easy" to provide a setter, because my method has a parameter (so <code>public void setActiveIndexesForSections(String name, String activeIndexes)</code> or <code>public void setActiveIndexesForSections(String name)</code>won't work). 
  What I came up with in the end is:</p>
  
  <p>Create a (generic) "Pseudo-Property-class":</p>
  
  <pre><code>// just a dummy class since the class is recreated at every request
  public class Property&lt;T&gt; implements Serializable {
  
      private T val;
  
      public Property(T val) {
          this.val= val;
      }
  
      public T getVal() {
          return val;
      }
  
              //no need to do anyhting
      public void setVal(T val) {
      }
  }
  </code></pre>
  
  <p>Change the bean method:</p>
  
  <pre><code>public Property&lt;String&gt; getActiveIndexesForSections(String holderName){
      String activeSections = "";
      for(Section s : sectionMap.get(holderName)){
          if (s.isActive())
          //add to the string
      }
      return new Property&lt;String&gt;(activeSections);
  }
  </code></pre>
  
  <p>And call it from the <code>index.xhtml</code>:</p>
  
  <pre><code>&lt;p:accordionPanel multiple="true" activeIndex="#{myController.getActiveIndexesForSections('whatever').val}"&gt;
  // bla bla...
  &lt;/p:accordionPanel&gt;
  </code></pre>
  
  <p>This works but obviously is a ugly hack/workaround.</p>
  
  <p>What is the proper way to handle a situation like this? Or is what I'm doing simply completely wrong?</p>