Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Button "OK"(Management of OK button in a form)
Button "OK" [message #1016714] Thu, 07 March 2013 13:03 Go to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi,
I have the following question: I have my form in Scout with many fields in which I have defined a set of validation rules (Exec Validate Value), and so far no problem.

Now on the OK button I customized the "Exec Click Action" to perform certain operations, that I want to be done only when all fields are correct according to various validation rules set.

When I click on OK button and at leat one field isn't valid, a popup is displayed automatically with a message (see image):
index.php/fa/13736/0/
but the instructions in the method "Exec Click Action" are still performed.

How do I figure out when it open this popup? What condition I should test?

Thanks in advance for help and suggestions
  • Attachment: Image.png
    (Size: 24.39KB, Downloaded 744 times)
Re: Button "OK" [message #1016729 is a reply to message #1016714] Thu, 07 March 2013 13:55 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I think that it is not common to have business logic in the ExecClickAction of the OK button. When the OK Button is clicked, it is clicked independently of the form state (invalid fields). The role of the OK Button is to trigger a doSave() on the form nothing more. (It is possible to call doSave() from another button or as reaction of a specific event)

After that the FormHanler will handle the form life-cycle. You can add additional checks to the build in checks (like the message box you mentioned):
* ExecCheckField
* ExecValidate
* ExecStore

ExecStore is only called if CheckField (build in and custom) and ExecValidate (build in and custom) are successful. I recommend you to move you logic there.

If you have two form hanlders (one for NEW and one for MODIFY) and your business logic is the same you can put it in a function that you call in both cases.

Does it help you?
Re: Button "OK" [message #1016738 is a reply to message #1016729] Thu, 07 March 2013 14:09 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Thank you fo ryour suggestion.
Now move my business logic from "Exec Click Action" of OK Button to "ExecStore".

I have a question: when I execute the ExecStore, how do I detect which fields have been corrected or changed? Is it possible?

[Updated on: Thu, 07 March 2013 14:32]

Report message to a moderator

Re: Button "OK" [message #1016810 is a reply to message #1016738] Thu, 07 March 2013 18:23 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
In typical application this does not matter, because the whole form is exported in the formData and sent to the server.

I think each field can provide information if its value has changed: with IFormField#isSaveNeeded().
I recommend you to make some deep tests, because I am not sure how reliable the information is (for example if the user make some inputs in the field and cancel them).
Re: Button "OK" [message #1017011 is a reply to message #1016810] Fri, 08 March 2013 15:22 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi Jeremie,
I moved my business logic in ExecStore of the handlers "NewHandler" and "ModifyHandler", because is the same.
When I click on OK Button, these methods are not called. What I forgot or wrong?
    @Order(30.0)
    public class OkButton extends AbstractOkButton {

      @Override
      protected String getConfiguredLabel() {
        return TEXTS.get("Ok");
      }

    }

    @Override
    public void execStore() throws ProcessingException {
      IOrderDetailsProcessService service = SERVICES.getService(IOrderDetailsProcessService.class);
      OrderDetailsFormData formData = new OrderDetailsFormData();
      exportFormData(formData);
      formData = service.store(formData);

      //Save order Information
      saveOrderInformation();
    }
Re: Button "OK" [message #1017223 is a reply to message #1017011] Mon, 11 March 2013 08:54 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
execStore of the FormHandler is called if there is some modification in the form.

Scout Forms check if there was a modification in any field (corresponding to the method: getXxxxField().isSaveNeeded() ) If so the form is considered as modified. In such a case execStore of the form handler is called.
You can "check" the state of your form: if you click the cancel button and one of the fields has been modified, a message box will appear.

You can "touch" the form (mark the form as modified) by calling touch() in the execPostLoad method of the form handler.
Re: Button "OK" [message #1017255 is a reply to message #1017223] Mon, 11 March 2013 10:38 Go to previous message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Thank you for this suggestion and explanation. Now works
Previous Topic:Export as war
Next Topic:Making AbstractDrawLineField persistent
Goto Forum:
  


Current Time: Tue Mar 19 03:58:41 GMT 2024

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

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

Back to the top