title: JSF nested objects set to null on submit
body: <p>I am facing a similar problem described in this SO thread <a href="https://stackoverflow.com/questions/45022342/why-does-jsf-null-out-a-nested-class-successfully-instantiated-in-the-backing-be">Why does JSF null out a nested class successfully instantiated in the backing bean?</a>
  I am having a simple form (JSF-2.2) to create an object with multiple nested objects and their respective properties. Instantiation happens successfully and I can see all objects and their children being not null but for some reason, when I submit the form, the entire object tree is getting set to null again. In the below example, the value template would result in </p>
  
  <blockquote>
    <p>javax.el.PropertyNotFoundException: Target Unreachable, 'null'
    returned null.</p>
  </blockquote>
  
  <p>because for some reason ArticleListConfiguration is being set to null right befor submit happens.</p>
  
  <pre><code>&lt;ui:composition template="../template/template.xhtml"&gt;
  &lt;ui:define name="content"&gt;
      &lt;h:form id="createArticleListForm"&gt;
          &lt;p:panel styleClass="content-panel"&gt;
              &lt;h:panelGrid
                      columns="2"
                      styleClass="borderless-grid"
                      columnClasses="create-article-list-panel, create-article-list-panel"&gt;
                  &lt;p:panel
                          id="listValuesPanel"&gt;
                      &lt;p:inputText
                              id="articleListName"
                              value="#{createArticleListController.articleList.name}"/&gt;
                      &lt;p:inputText
                              id="articleListSize"
                              maxlength="3"
                              value="#{createArticleListController.articleListSize}"&gt;
                      &lt;/p:inputText&gt;
                      &lt;p:selectBooleanCheckbox
                              id="saveArticleListConfigurationAsTemplate"
                              value="#{createArticleListController.articleList.articleListConfiguration.template}"/&gt;
                      &lt;h:panelGrid
                              columns="1"&gt;
                          &lt;p:fileUpload
                                  id="upload"
                                  widgetVar="fileUploadWidget"
                                  fileUploadListener="#{createArticleListController.uploadImages}"
                                  multiple="true"
                                  onstart="submitSelection()"
                                  oncomplete="handleMultiFileUploadRequest(PF('fileUploadWidget'));"
                                  allowTypes="/(\.|\/)(jpg|png)$/"
                                  styleClass="ui-widget"/&gt;
                          &lt;p:remoteCommand
                                  name="submitSelection"
                                  process="@this"/&gt;
                      &lt;/h:panelGrid&gt;
                  &lt;/p:panel&gt;
              &lt;/h:panelGrid&gt;
              &lt;br/&gt;
              &lt;p:commandButton
                      id="createArticleListButton"
                      process="@this @form"
                      value="#{contentController.getContent('createArticleList')}"
                      actionListener="#{createArticleListController.onCreate()}"/&gt;
          &lt;/p:panel&gt;
      &lt;/h:form&gt;
  &lt;/ui:define&gt;
  </code></pre>
  
  <p></p>
  
  <p>And here is the backing bean</p>
  
  <pre><code>@ManagedBean
  @ViewScoped
  public class CreateArticleListController extends AbstractController {
  
  @Inject
  private ArticleListService articleListService;
  
  private ArticleList articleList;
  private Integer articleListSize;
  private List&lt;Pair&lt;String, InputStream&gt;&gt; files;
  
  
  @PostConstruct
  public void init() {
      //The constructor of ArticleList creates and attaches instances of all necessary nested objects
      articleList = new ArticleList();
      files = new ArrayList&lt;&gt;();
  }
  
  public void onCreate() throws IOException {
      articleListService.create(articleList, files);
      navigateTo("articleListOverview");
  }
  
  public void uploadImages(FileUploadEvent event) {
      try {
          files.add(Pair.of(event.getFile().getFileName(), event.getFile().getInputstream()));
      } catch (IOException e) {
          LOGGER.log(Level.ERROR, "Error uploading files");
          JsfMessageUtils.sendErrorMessageToUser("Error uploading files");
      }
  }
  
  public ArticleList getArticleList() {
      return articleList;
  }
  
  public void setArticleList(ArticleList articleList) {
      this.articleList = articleList;
  }
  
  public Integer getArticleListSize() {
      return articleListSize;
  }
  </code></pre>
  
  <p>}</p>