title: ViewScoped CDI bean recreated after some AJAX requests
body: <p>I have a CDI ViewScoped bean and a JSF page. After a couple of AJAX requests the bean somehow recreated.
  Here is the full code of the application:</p>
  
  <p>index.xhtml</p>
  
  <pre class="lang-xhtml prettyprint-override"><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://xmlns.jcp.org/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:ui="http://xmlns.jcp.org/jsf/facelets"&gt;
      &lt;h:head&gt;
          &lt;title&gt;Facelet Title&lt;/title&gt;
      &lt;/h:head&gt;
      &lt;h:body&gt;
          Hello from Facelets
          &lt;h:form&gt;
              &lt;h:inputText value="#{questionBean.newTag}"&gt;&lt;/h:inputText&gt;
              &lt;h:commandButton value="Add Tag"&gt;
                  &lt;f:ajax listener="#{questionBean.addTag()}" execute="@form" render="@form"&gt;&lt;/f:ajax&gt;
              &lt;/h:commandButton&gt;
              &lt;ui:repeat value="#{questionBean.tagsOfQuestion}" var="tag"&gt;
                  &lt;h:outputLabel value="#{tag}"&gt;&lt;/h:outputLabel&gt;
                  &lt;h:commandButton value="X"&gt;
                      &lt;f:ajax event="click" listener="#{questionBean.removeTag(tag)}" render="@form" execute="@form"/&gt;
                  &lt;/h:commandButton&gt;
              &lt;/ui:repeat&gt;
          &lt;/h:form&gt;
      &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is the backing CDI bean
  QuestionBean.java</p>
  
  <pre><code>    import java.util.ArrayList;
      import java.util.Date;
      import java.util.List;
      import javax.faces.view.ViewScoped;
      import javax.inject.Named;
  
      @Named
      @ViewScoped    
      public class QuestionBean {
          private String newTag;
          private List&lt;String&gt; tagsOfQuestion = new ArrayList&lt;String&gt;();
          private Date dateCreated = new Date();
  
      public QuestionBean(){
          System.out.println("Date Created : "+dateCreated);
      }
  
      public void addTag(){
          if(!newTag.isEmpty()){
              getTagsOfQuestion().add(newTag);
          }
          newTag = "";
      }
  
      public void removeTag(String tagToRemove){
          getTagsOfQuestion().remove(tagToRemove);
      }
  
      public String getNewTag() {
          return newTag;
      }
  
      public void setNewTag(String newTag) {
          this.newTag = newTag;
      }
  
      public List&lt;String&gt; getTagsOfQuestion() {
          return tagsOfQuestion;
      }
  
      public void setTagsOfQuestion(List&lt;String&gt; tagsOfQuestion) {
          this.tagsOfQuestion = tagsOfQuestion;
      }
  
  }
  </code></pre>