neutrino36
(neutrino neutrino)
June 17, 2020, 12:39pm
#1
Hi,
I have to revolve the next issue:
In an Edit screen when I change a field attribute I need to change automatically another attribute.
see below:
@Subscribe
public void onInit(InitEvent event) {
transactionDc.addItemPropertyChangeListener((e -> checkQuote()));
}
public void checkQuote() {
if (transactionDc.getItem().getQuAmount() != null) {
transactionDc.getItem().setStatus(TrStatusEnum.EVAL);
}
Unfortunately I have stackoverflow when I try to modify the QuAmount value.
What is the right approach?
BR,
-n
klaus
(Klaus Pfeiffer)
June 17, 2020, 12:45pm
#2
transactionDc.addItemPropertyChangeListener(e -> {
if (e.getProperty().equals("quAmount")) {
checkQuote()
}
});
This way you won’t trigger the event again, when you change the “status” programmatically.
1 Like
neutrino36
(neutrino neutrino)
June 17, 2020, 12:53pm
#3
I manage to get rid of stackoverflow but the problem is when I save (ok button in edit), the modification doesn’t appear in Browser. I have to open again the Editor in order to persist the changes.
@Subscribe
public void onInit(InitEvent event) {
transactionDc.addItemPropertyChangeListener((e ->{
if( e.getItem().getQuAmount()!=null)
{
transactionDc.getItem().setStatus(TrStatusEnum.EVAL);
}
if( e.getItem().getProfAmount()!=null)
{
transactionDc.getItem().setStatus(TrStatusEnum.ORDERED);
}
}));
klaus
(Klaus Pfeiffer)
June 17, 2020, 1:11pm
#4
Try:
getScreenData().getDataContext().commit();
getScreenData().loadAll();
neutrino36
(neutrino neutrino)
June 17, 2020, 1:16pm
#5
The key is to treat every combination, otherwise you’ll get stackoverflow…
Now it works.
getScreenData().getDataContext().commit();
getScreenData().loadAll();
is not necesarry.
Thank you!!