I’m following the example to create and edit online records within the DataGrid, apparently everything works fine, but by clicking on the Ok button the registration does not persist. What am I doing wrong?
XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
caption="msg://browseCaption"
class="com.iis.app.mediesfera.web.catalog.ctlpais.CtlPaisBrowse"
focusComponent="ctlPaisTable"
lookupComponent="ctlPaisTable"
messagesPack="com.iis.app.mediesfera.web.catalog.ctlpais">
<dsContext>
<collectionDatasource id="ctlPaisCollectionDs"
class="com.iis.app.mediesfera.entity.catalog.CtlPais"
view="ctlPais-view">
<query>
<![CDATA[select e from mdsf$CtlPais e]]>
</query>
</collectionDatasource>
</dsContext>
<dialogMode height="600"
width="800"/>
<layout expand="ctlPaisTable"
spacing="true">
<filter id="filter"
applyTo="ctlPaisTable"
datasource="ctlPaisCollectionDs"
useMaxResults="false">
<properties include=".*"/>
</filter>
<dataGrid id="ctlPaisTable"
datasource="ctlPaisCollectionDs"
editorEnabled="true"
settingsEnabled="false"
width="100%">
<actions>
<action id="create"/>
<action id="edit"/>
<action id="remove"/>
<action id="refresh"/>
<action id="excel"/>
</actions>
<columns>
<column id="codigo"
property="id"/>
<column id="nombre"
property="nombre"/>
</columns>
<rowsCount/>
<buttonsPanel id="buttonsPanel"
alwaysVisible="true">
<button id="createBtn"
action="ctlPaisTable.create"/>
<button id="editBtn"
action="ctlPaisTable.edit"/>
<button id="removeBtn"
action="ctlPaisTable.remove"/>
<button id="refreshBtn"
action="ctlPaisTable.refresh"/>
<button id="excelBtn"
action="ctlPaisTable.excel"/>
</buttonsPanel>
</dataGrid>
</layout>
</window>
Browse
public class CtlPaisBrowse extends AbstractLookup {
@Inject
private DataGrid<CtlPais> ctlPaisTable;
@Inject
private CollectionDatasource<CtlPais, String> ctlPaisCollectionDs;
@Override
public void init(Map<String, Object> params) {
ctlPaisTable.addAction(new CreateAction(ctlPaisTable) {
@Override
public void actionPerform(Component component) {
CtlPais pais = metadata.create(CtlPais.class);
ctlPaisCollectionDs.addItem(pais);
ctlPaisTable.edit(pais);
}
});
}
}