The method in the controller that I use to save the entity; part of my screen descriptor:
public class CardItemEdit extends AbstractEditor<CardItem> {
public void save() {
CardItem cardItem = new CardItem();
cardItem.setCardType(cardType.getValue());
cardItem.setCardSubType(cardSubType.getValue());
cardItem.setCardOutcomeNumber(cardOutcomeNumber.getValue());
cardItem.setCardOrganization(cardOrganization.getValue());
cardItem.setCardDeliveryMethod(cardDeliveryMethod.getValue());
cardItem.setCardDate(cardDate.getValue());
cardItem.setCardCreationDate(cardCreationDate.getValue());
cardItem.setCardAdditionalInformation(cardAdditionalInformation.getValue());
cardItem.setRegistratorName(registratorName.getValue());
cardItemService.saveCardItem(cardItem);
}
// SKIPPED
<actions>
<action id="save" caption="mainMsg://actions.Ok" invoke="save" />
<action id="cancel" caption="mainMsg://actions.Cancel" invoke="cancel" />
</actions>
<hbox id="actionsPane" spacing="true" visible="true">
<button id="saveBtn" action="save"/>
<button id="cancelBtn" action="cancel"/>
</hbox>
When I press “saveBtn” the entity is saved to the database and I want to close the editor. In addition, I have the “cancelBtn” button and I want to close the editor by clicking on it.
Service CardItemServiceBean:
public class CardItemServiceBean implements CardItemService {
@Inject
private Persistence persistence;
@Override
public UUID saveCardItem(CardItem cardItem) {
try(Transaction tx = persistence.createTransaction()) {
persistence.getEntityManager().persist(cardItem);
tx.commit();
}
return cardItem.getId();
}
// SKIPPED
How to achieve this?
I would be very grateful for the information. Thanks to all.