I use a lookupField to add record in a COMPOSITION data collection. For remove record I used a generated column. I got 2 problem in below code.
-
After “Save”, all removed COMPOSITION table record still exists.
In Edit mode without any problem on adding record, but the removed record after save edit again all come back. -
Cannot save the added record in Create mode.
When added record in COMPOSITION table on a NEW issue, the following error display.
<instance id="issueDc" class="com.yyy.xxx.entity.Issue">
<view extends="_local">
<property name="issueScheme" view="_minimal"/>
</view>
<loader/>
<collection id="issueSchemeDc" property="issueScheme"/>
</instance>
......
<lookupField id="dummyList" caption="Project Scheme" optionsContainer="projectSchemeDc"/>
<groupTable id="issueSchemeTable" dataContainer="issueSchemeDc" width="100%" height="120"
stylename="no-header borderless no-vertical-lines no-horizontal-lines no-stripes small">
<columns>
<column id="projectSchemeCode"/>
</columns>
</groupTable>
@Subscribe
public void onInit(InitEvent event) {
issueSchemeTable.addGeneratedColumn("Remove",1, entity -> {
LinkButton field = uiComponents.create(LinkButton.class);
field.setCaption("");
field.setIcon("icons/remove.png");
field.setAction(new BaseAction("viewDescDetail")
.withCaption("View Description Detail")
.withHandler(clickEvent -> {
issueSchemeDc.getMutableItems().remove(issueSchemeTable.getSingleSelected());
})
);
return field;
});
}
@Subscribe("dummyList")
public void onDummyListValueChange(HasValue.ValueChangeEvent<ProjectScheme> event) {
if (event.isUserOriginated()) {
issueScheme newIssueScheme = metadata.create(issueScheme.class);
newIssueScheme.setIssue(d01IssueDc.getItem());
newIssueScheme.setProjectSchemeId(event.getValue().getProjectSchemeCode());
newIssueScheme.setProjectSchemeCode(oneProjectScheme.getProjectSchemeCode());
issueSchemeDc.getMutableItems().add(newIssueScheme);
dummyList.setValue(null);
}
}