Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » execStore() and Confirmation
execStore() and Confirmation [message #1415370] Tue, 02 September 2014 16:12
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I am doing code review and bug correction in a Scout Application.

I have seen this today and wanted to share it with you:
@Override
protected void execStore() throws ProcessingException {
  int button = MessageBox.showYesNoMessage(TEXTS.get("MessageBoxTitle"), TEXTS.get("ConfirmSave"), null);
  if(button == MessageBox.YES_OPTION) {
    IMyService service = SERVICES.getService(IMyService.class);
    MyFormData formData = new MyFormData();
    exportFormData(formData);
    formData = service.store(formData);
  }
}

What is wrong with this code snippet?

If the user clicks on "No" in the dialog, nothing is sent to the server... This is what the developer wanted.

But the problem is that when the user clicks no, the scout client will consider the form as stored.

With Scout 4.1.0-SNAPSHOT (work in progress for the Eclipse Scout Mars release) you can do this:
@Override
protected void execStore() throws ProcessingException {
  int button = MessageBox.showYesNoMessage(TEXTS.get("MessageBoxTitle"), TEXTS.get("ConfirmSave"), null);
  if(button == MessageBox.YES_OPTION) {
    IMyService service = SERVICES.getService(IMyService.class);
    MyFormData formData = new MyFormData();
    exportFormData(formData);
    formData = service.store(formData);
  } else {
    setFormStored(false);
  }
}


If you are on the Luna Branch, Bug 437361 is not included in the framework. Just do the same by hand:
@Override
protected void execStore() throws ProcessingException {
  int button = MessageBox.showYesNoMessage(TEXTS.get("MessageBoxTitle"), TEXTS.get("ConfirmSave"), null);
  if(button == MessageBox.YES_OPTION) {
    IMyService service = SERVICES.getService(IMyService.class);
    MyFormData formData = new MyFormData();
    exportFormData(formData);
    formData = service.store(formData);
  } else {
    VetoException e = new VetoException("Form was not stored");
    e.consume();
    throw e;
  }
}


By the way, if you want to ask something to the user, I think that AbstractFormHandle#execValidate() is a better place to do it:
@Override
protected boolean execValidate() throws ProcessingException {
  return MessageBox.showYesNoMessage(TEXTS.get("MessageBoxTitle"), TEXTS.get("ConfirmSave"), null) == MessageBox.YES_OPTION;
}


I hope this helps...

[Updated on: Tue, 02 September 2014 16:49]

Report message to a moderator

Previous Topic:Dependency Injection + Eclipse Scout?
Next Topic:NoSQL and Scout
Goto Forum:
  


Current Time: Fri Mar 29 09:41:12 GMT 2024

Powered by FUDForum. Page generated in 0.01939 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top