Vaadin getting null pointer when trying to add an item to sqlContainer

I am very new to vaadin (and to java).

I have a table that has SQLcontainer:

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 TextField to populate data in a 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 string ** cont.getContainerProperty (itemId, "id"). setValue (dataResult);

Am I doing something wrong? and what is a null pointer?

let me know if something is unclear.

Please help, thanks in advance.

+5
source share
2 answers

This expression returns null:

cont.getContainerProperty(itemId , "id")

null. NullPointerException. , .

+2

, Vaadin , , , , getContainerProperty (itemId, property)

+4

All Articles