Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Weird problem with Table component
Hello Everyone,
I am trying to display a table that has 2 columns, Profile Id and Profile Name. Profile Id is an Integer field with values from 1 to n. The Profile Name is a String but in the table I modify it to be a link button such that onClick it displays a new window.
Everything is good except that the table always displays only n-1 rows of the n rows returned. The relevant code snippets are below. Can anyone tell me what is it that I am doing wrong?
Table table = new Table();
window.addComponent(table);
ProfileManager manager = new ProfileManager();
List<Profile> profiles = manager.listProfiles();
table.setPageLength(profiles.size());
table.setSizeFull();
table.addContainerProperty("profileId", Long.class, null, "Profile Id", null, Table.ALIGN_CENTER);
table.addContainerProperty("profileName", Button.class, null, "Profile Name", null, Table.ALIGN_LEFT);
Object[] cells = new Object[2];
for (Profile profile : profiles) {
table.addItem(cells, null);
cells[0] = (Long) profile.getProfileId();
Button editProfile = new Button(profile.getProfileName());
cells[1] = editProfile;
editProfile.setData(profile.getProfileId());
editProfile.addStyleName("link");
editProfile.addListener(new EditProfileListener());
}
The problem is the first pass of your for loop. You're passing in an array of nulls. Bump your call to table.addItem(cells, null) to the bottom of your loop.