DB: Oracle
Below is my code which will be very similar to the code from Vaadin Address book tutorial - PersonForm.
While Performing Commit on the sqlcontainer, its not committing the change to the row back to the table. Please help me out in this, Vaadin should me very simple, I am missing something here.
Code:--------------------------------------------
import java.util.Arrays;
import java.util.List;
import com.example.db.INVColumnView;
import com.example.db.INVFieldFactory;
import com.example.invmgmt.InvmgmtApplication;
import com.vaadin.data.Item;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Form;
import com.vaadin.ui.HorizontalLayout;
@SuppressWarnings(“serial”)
public class INVMainForm extends Form implements ClickListener {
private Button save = new Button("Save", (ClickListener) this);
private Button cancel = new Button("Cancel", (ClickListener) this);
private Button edit = new Button("Edit", (ClickListener) this);
private InvmgmtApplication app;
public INVMainForm(InvmgmtApplication app) {
this.app = app;
HorizontalLayout footer = new HorizontalLayout();
footer.setSpacing(true);
footer.addComponent(edit);
footer.addComponent(save);
footer.addComponent(cancel);
footer.setVisible(false);
setFooter(footer);
}
@Override
public void setItemDataSource(Item newDataSource) {
if(newDataSource != null){
List<Object> orderedProperties = Arrays.asList(INVColumnView.NATURAL_COL_ORDER_NEWFORM);
super.setFormFieldFactory(new INVFieldFactory());
super.setItemDataSource(newDataSource,orderedProperties);
setWriteThrough(false);
setReadOnly(true);
getFooter().setVisible(true);
}else{
super.setItemDataSource(null);
getFooter().setVisible(false);
}
}
public void setReadOnly(boolean readOnly){
super.setReadOnly(readOnly);
save.setVisible(!readOnly);
cancel.setVisible(!readOnly);
edit.setVisible(readOnly);
}
public void buttonClick(ClickEvent event) {
Button source = event.getButton();
if(source == save){
if(!isValid()){
return;
}
commit();
setReadOnly(true);
app.showListView();
}else if(source == cancel){
discard();
setReadOnly(true);
app.showListView();
}else if(source == edit){
setReadOnly(false);
}
}
}