I'm very new to vaadin ( and to java).
i have an table that has an SQLcontainer like so :
public class ProjectTable extends Table {
      public ProjectTable(final DocumentmanagerApplication app) {
          setSizeFull();
          setContainerDataSource(app.getDbHelp().getProjectContainer());
          setImmediate(true);
          commit();
          setSelectable(true);
      }
    }
i have a button and a TextField , to fill data in the table
public void buttonClick(ClickEvent event)
    {
        SQLContainer cont = h.getAssetContainer();
        String dataResult = tf.getValue().toString(); // TEXT FIELD 
        System.out.println(dataResult);
        Object itemId = cont.addItem(); // cont is the container
        **cont.getContainerProperty(itemId , "id").setValue(dataResult);      // BUG IS HERE !!! **  
try {
            cont.commit();
        } catch (UnsupportedOperationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
i keep getting a " null pointer exception" no matter what i do. on the line **cont.getContainerProperty(itemId , "id").setValue(dataResult);
am i doing anything wrong ? and what is null pointer ?
please inform me if anything was unclear.
please help , thanks in advance.
BTW, if you have a Vaadin Table and you applied a Filter to it, you need to remove it before, if not probably you will get a null pointer exception in the getContainerProperty(itemId, property) method
This expression returns null:
cont.getContainerProperty(itemId , "id")
And then you try to invoke a method on null. This causes the NullPointerException. So have a look, why the container does not provide a non-null value for the key at the time you invoke it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With