title: Prime faces CRUD Operations
body: <blockquote>
    <p>I am trying to do Insert Operation in a table. I display exiting records in a datatable and details are displayed in a panelGrid below the dataTable on selecting each row. panelGrid with blank inputText boxes are shown when user click NEW button. User Submits the new record and dataTable is refreshed.</p>
  </blockquote>
  
  <p>On submit, I am getting error : </p>
  
  <p>Nov 22, 2011 5:02:22 PM com.sun.faces.lifecycle.ProcessValidationsPhase execute
  WARNING: Argument Error: Parameter targetClass is null
  java.lang.NullPointerException: Argument Error: Parameter targetClass is null</p>
  
  <p>Code is Given below:</p>
  
  <pre><code>&lt;p:outputPanel header="MyTable Records" rendered="true" id="panel_MyTable"&gt;         
      &lt;p:dataTable id="table_MyTable" value="#{myBean.records}" var="dataMyTable" onRowSelectUpdate="details_MyTable" selection="#{myBean.currentRec}" update="submitButton"&gt;
           &lt;p:column&gt;
                 &lt;f:facet name="header"&gt;
                      &lt;h:outputLabel value="Label 1" /&gt;
                 &lt;/f:facet&gt;
                 &lt;h:outputLabel value="#{dataMyTable.Field1}"/&gt;
           &lt;/p:column&gt;
  
           &lt;p:column&gt;
               &lt;f:facet name="header"&gt;
                   &lt;h:outputLabel value="Label 2" /&gt;
               &lt;/f:facet&gt;
               &lt;h:outputLabel value="#{dataMyTable.Field2}"/&gt;
           &lt;/p:column&gt;
  
           &lt;f:facet name="footer"&gt;
                 &lt;p:commandButton value="New"  image="ui-icon ui-icon-add" actionListener="#{myBean.prepareForInsertAction}" update="details_myTable,submitButton" /&gt;
           &lt;/f:facet&gt;
    &lt;/p:dataTable&gt;
  &lt;/p:outputPanel&gt;
  
  
  
  &lt;h:panelGrid id="details_MyTable"&gt;
      &lt;h:outputLabel value="Label 1"/&gt;
          &lt;p:inputText readonly="#{myBean.editMode ? false : true}" value="#{myBean.editMode ? myBean.newRec.Field1 : myBean.currentRec.Field1}" /&gt;
          &lt;h:outputLabel value="Label 2"/&gt;
          &lt;p:inputText readonly="#{myBean.editMode ? false : true}" value="#{myBean.editMode ? myBean.newRec.Field2 : myBean.currentRec.Field2}" /&gt;
  &lt;/h:panelGrid&gt;
  
  &lt;p:commandButton id="submitButton" actionListener="#{myBean.createAction}" value="Submit" update="table_MyTable,details_MyTable" rendered="#{myBean.editMode ? true : false}"/&gt;
  
  
  
  
  @ManagedBean(name="myBean")
  @ViewScoped
  public class MyBean
  {
      public static List&lt;MYTABLE&gt; records;
      MYTABLE currentRec;
      Boolean editMode=false;
  
      public MyBean(){
          records = MYTABLE_CRUD.getAllRecs();
          currentRec = new MYTABLE();
      }
  
      public void prepareForInsertAction(){
          newRec = new MYTABLE();
          editMode = true;
      }
      public void setCurrentRec(MYTABLE v_currentRec) {
          this.currentRec = v_currentRec;
          editMode = false;
      }
  
  }
  </code></pre>