Hi,
I’ve been browsing forums and example for two days now and i can’t get something to work.
I simple have a JPAContainer, linked with a Entity. I set this container as a datasource for a editable table.
So far everything work fine, table get loaded with data and i can modify the data.
When i try to save is the probleme, nothing happend… nothing get saved… if i refresh the page, my changed value still there
but when i check in the database, nothing has really changed.
here is my simple code,
what’s wrong ?
Thanks
package ca.exagon.demovaadin.view;
import javax.persistence.EntityManager;
import ca.exagon.demovaadin.DemovaadinUI;
import ca.exagon.demovaadin.model.RrpadTag;
import com.vaadin.addon.jpacontainer.JPAContainer;
import com.vaadin.addon.jpacontainer.JPAContainerFactory;
import com.vaadin.data.Container.Filter;
import com.vaadin.data.util.filter.Compare;
import com.vaadin.server.VaadinSession;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Table;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Button.ClickEvent;
public class TestScope extends VerticalLayout {
private static final long serialVersionUID = 1L;
//final EntityManager em = (EntityManager) VaadinSession.getCurrent().getAttribute(“ENTITYMANAGER”);
//private JPAContainer JPAtag;
public TestScope() {
construirePage();
}
private void construirePage() {
final JPAContainer JPAtag = JPAContainerFactory.make(RrpadTag.class,DemovaadinUI.getPU());
// Some filter to reduce number of row…
Filter filter1 = new Compare.Greater(“patcleint”, 163800);
Filter filter2 = new Compare.Less(“patcleint”, 163900);
JPAtag.addContainerFilter(filter1);
JPAtag.addContainerFilter(filter2);
final Table table = new Table();
table.setImmediate(true);
table.setEditable(true);
table.setReadOnly(false);
table.setContainerDataSource(JPAtag);
table.setVisibleColumns(new Object {“patcleint”,“pattaucal”});
Button btnCommit = new Button(“Commit”);
btnCommit.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
table.commit();
JPAtag.commit();
}
});
this.addComponent(table);
this.addComponent(btnCommit);
}
}
13313.java (1.79 KB)