Hi,
I’m following a couple of posts among the tutorials and documentation trying to understand why nothing is being commited to the DB.
Running CUBA 7.2.7 on Java 11 for this.
My sources are this demo project, the suggestion posted here and I read and checked what was suggested in this post about making data writable in screen descriptor and dataContext.commit()
.
I have browser editor screen pair. First the editor screen.
In the screen controller the snippet below isn’t working, as in nothing turns up in the database, then I click the button which invokes commitData()
. This applies to either table or form component being tested.
public void commitData() {
dataContext.commit();
}
Now if I subscribe to, for example, the form it does work. Which is good but CUBA shows a warning about this in Studio.
@Subscribe("form")
public void commitData() {
dataContext.commit();
}
In the editor screen I use any attribute of type string
for the sake of simplicity and understanding, let’s say name and ID field.
Now in the browse screen I try to reproduce a working implementation, as in the examples I linked above, to save the locale in a generated column then the button is clicked.
@Subscribe
private void onInit(InitEvent event) {
informationsTable.addGeneratedColumn("language", entity -> {
LookupField<String> lookupField = uiComponents.create(LookupField.TYPE_STRING);
List<String> locales = new ArrayList<>(globalConfig.getAvailableLocales().keySet());
lookupField.setOptionsList(locales);
lookupField.setWidth("100%");
return lookupField;
});
}
public void commitData() {
dataContext.commit();
}
Data is set to be writable and in the screen descriptor I add the button same as before
<button id="commitBtn" invoke="commitData" caption="Commit"/>
Yet in the browse screen nothing is commited to the database even if I @Subscribe
.
I posted not long ago a question about commiting data in this post. For my question here I use the same demo project as in the other post extending it with the code posted based on the examples linked to.
What am I doing wrong? Why is the data being saved and not saved? Especially I would be highly interested on how to achieve saving the selection of a column added to a table using the addGeneratedColumn()
method and of the selection of a RadioButtonGroup
as asked in this post.
Thank you very much!