Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Indicating in execStore() that the form is not stored.
Indicating in execStore() that the form is not stored. [message #1385857] Wed, 11 June 2014 16:56 Go to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Typically the execStore() function of the a formHandler look like this:
@Override
protected void execStore() throws ProcessingException {
  IExampleService service = SERVICES.getService(IExampleService.class);
  ExampleFormData formData = new ExampleFormData();
  exportFormData(formData);
  formData = service.store(formData);
}


If something goes wrong an exception is triggered. It produces a MessageBox and for the user the form is leaved touched (meaning Form#isSaveNeeded() will still be true).

I work with another pattern because I need to import error markers from the server in the client application. This works fine, but I have no possibility to tell scout that the form was not stored server-side.

If you look at AbstractForm#storeStateInternal() implementation you notice that the m_formStored flag is used to indicate that the form was'nt stored:
protected void storeStateInternal() throws ProcessingException {
  //...
  try {
    rebuildSearchFilter();
    m_searchFilter.setCompleted(true);
    getHandler().onStore();
    execStored();
  }
  catch (ProcessingException e) {
    // clear search
    if (m_searchFilter != null) {
      m_searchFilter.clear();
    }
    // store was not successfully stored
    m_formStored = false;
    throwVetoExceptionInternal(e);
    //...


I was thinking I can do something like this in my execStore():
@Override
protected void execStore() throws ProcessingException {
  //call server
  if <error marker in formData> {
    //special logic: import error markers on the fields
    setFormStored(false);
  } else {
    //default case
  }
}


The problem is that the current implementation really expects that an Exception is raised if the form was not saved server-side.

See the doSave() implementation:
//...
try {
  m_closeType = IButton.SYSTEM_TYPE_NONE;
  // ensure all fields have the right save-needed-state
  checkSaveNeeded();
  validateForm();
  m_closeType = IButton.SYSTEM_TYPE_SAVE;
  if (isSaveNeeded()) {
    storeStateInternal();
    markSaved();
  }
}
//...


In my opinion the markSaved() call should only occurred if isFormStored() returns true.

This could be changed and ensured with a unit test.

What do you think?

Should I open a bug?
Re: Indicating in execStore() that the form is not stored. [message #1386084 is a reply to message #1385857] Fri, 13 June 2014 11:28 Go to previous message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I got positive feedback from Ivan Motsch, so I opened Bug 437361.

Feel free to provide feedback. Especially if you think this change will break your application.
Previous Topic:Jetty server hook for configuration
Next Topic:Web Service Upload/Download File
Goto Forum:
  


Current Time: Thu Apr 25 11:03:40 GMT 2024

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

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

Back to the top