Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Update / Refresh a TableField after an update / change(I can't update the TableField after change data into a form and to press OK)
Update / Refresh a TableField after an update / change [message #1016705] Thu, 07 March 2013 12:33 Go to next message
Henrique Meira is currently offline Henrique MeiraFriend
Messages: 13
Registered: November 2012
Junior Member
I created a form, called TitleForm, and I added a TableField, called DetailTableField. In this DetailTableField I added an Edit menu to open another form, called DetailForm, obviously, for changes of the details from a title.

Until this point, everything work fine.

When I press the OK button, the changes are stored at database.

The problem is when the DetailForm is closed. The DetailTableField from TitleForm not is refreshed/reloaded.

I include the following code in my execAction method:

            protected void execAction() throws ProcessingException {

              DetailForm form = new DetailForm();
              form.setGcf_titulo_det_id( getTable().getGcf_titulo_det_idColumn().getSelectedValue() );
              form.startModify();
              form.waitFor();

              if (form.isFormStored()) {
                reloadTableData(); // try 1
                getDetailTableField().reloadTableData(); // try 2
              }

            }


Need I to write any other code to update the DetailTableField?

[Updated on: Mon, 11 March 2013 13:19]

Report message to a moderator

Re: Update / Refresh a TableField after an update / change [message #1016719 is a reply to message #1016705] Thu, 07 March 2013 13:22 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
The following line should be enouhg:
        if (form.isFormStored()) {
          reloadPage();
        }

Re: Update / Refresh a TableField after an update / change [message #1017023 is a reply to message #1016719] Fri, 08 March 2013 16:48 Go to previous messageGo to next message
Henrique Meira is currently offline Henrique MeiraFriend
Messages: 13
Registered: November 2012
Junior Member
Thanks Urs Beeli.

I get a compilation error:

"The method reloadPage() is undefined for the type TitleForm.MainBox.DetailBox.DetailField.Table.AddMenu".

reloadTableData() is a method of an AbstractTable, but reloadPage not.
Re: Update / Refresh a TableField after an update / change [message #1017166 is a reply to message #1016705] Sun, 10 March 2013 11:47 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Henrique Meira wrote on Thu, 07 March 2013 13:33

When I press the OK button, the changes are stored at database.

The problem is when the DetailForm is closed. The DetailTableField from TitleForm not is refreshed/reloaded.

(...)

Do I need to write any other code to update the DetailTableField?


You are correct: It works as you described. You will need to write code corresponding to the logic you want to use: I think it depends on your business logic, and what you can do in your master-form (in your example TitleForm) and in the auxiliary forms (in your case DetailForm).

* Pattern 1: Modifications in the auxiliary form are directly persisted when this form is closed.

(I think that this is your use case)

Have a look at this example: the main form of the application QuestionListForm contains a TableField: QuestionsField. When a question is created (with the CreateQuestionMenu) or edited (with the EditQuestionMenu) the QuestionForm is opened (with startNew() or startModified()). In this form, the modifications are stored. In both cases I have:

  if (form.isFormStored()) {
    reloadForm();
  }


The reload Form function, is a private function I have written:
  private void reloadForm() throws ProcessingException {
    IQuestionsListProcessService service = SERVICES.getService(IQuestionsListProcessService.class);
    QuestionsListFormData formData = new QuestionsListFormData();
    exportFormData(formData);
    formData = service.load(formData);
    importFormData(formData);
  }




* Pattern 2: Modifications in the auxiliary form should be persisted when the master form is closed.
This pattern is useful in following use case:
- Master form opened
- Auxiliary form is opened and saved (for one or multiple rows of the TableField)
- Cancel button hit on the master form

In this case when the user closes the master form with cancel, he likes to cancel the whole edit (including the changes made with the auxiliary forms). The changes are in the database only when the master form is closed with OK.

Have a look at: QuestionForm its contains a Table field for choices: ChoicesFied. A choice can be added (AddChoiceMenu) or edited (EditChoiceMenu). This is realized with the auxiliary form ChoiceForm that is started in both case with startEdit(). On close of this form, if the user click on OK, the data are updated in the table (either in a new row in case of NEW or in the selected row in case of EDIT).

----

Side note: the code is old and was made for Indigo Eclipse. If you want to check it out with Juno consider the code in preview branch (it might be nearer to Juno).
Re: Update / Refresh a TableField after an update / change [message #1017219 is a reply to message #1017023] Mon, 11 March 2013 08:45 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Henrique Meira wrote on Fri, 08 March 2013 17:48
Thanks Urs Beeli.

I get a compilation error:

"The method reloadPage() is undefined for the type TitleForm.MainBox.DetailBox.DetailField.Table.AddMenu".

reloadTableData() is a method of an AbstractTable, but reloadPage not.


I was commenting on your code a few posts above mine:

            protected void execAction() throws ProcessingException {

              DetailForm form = new DetailForm();
              form.setGcf_titulo_det_id( getTable().getGcf_titulo_det_idColumn().getSelectedValue() );
              form.startModify();
              form.waitFor();

              if (form.isFormStored()) {
                reloadTableData(); // try 1
                getDetailTableField().reloadTableData(); // try 2
              }

            }


To me, that looked like the code on your PageWithTable, I merely suggested to replace this with

            protected void execAction() throws ProcessingException {
              DetailForm form = new DetailForm();
              form.setGcf_titulo_det_id( getTable().getGcf_titulo_det_idColumn().getSelectedValue() );
              form.startModify();
              form.waitFor();

              if (form.isFormStored()) {
                reloadPage();
              }

            }


Assuming the execAction is part of an AbstractPageWithTable, this should work, because reloadPage() is defined in AbstractPage.

I am succesfully using this on the PersonPage of the Minicrm tutorial, it makes sure that if I add a new person to the DB using a form, the table is then page (and therefore the table) is reloaded.
Re: Update / Refresh a TableField after an update / change [message #1017281 is a reply to message #1017219] Mon, 11 March 2013 13:33 Go to previous messageGo to next message
Henrique Meira is currently offline Henrique MeiraFriend
Messages: 13
Registered: November 2012
Junior Member
Thank you again Beeli, but I call a form from another form, so, it's an AbstractForm and not a PageWithTable.

The solution suggest by Jeremie works fine.
Re: Update / Refresh a TableField after an update / change [message #1017284 is a reply to message #1017166] Mon, 11 March 2013 13:37 Go to previous messageGo to next message
Henrique Meira is currently offline Henrique MeiraFriend
Messages: 13
Registered: November 2012
Junior Member
Jeremie, thank you very much for your time.

Problem solved!

It's work very well.

p.s.: I'll pull the MCQS project, will be very useful.

p.s2.: Do you know others (open) projects based on Eclipse Scout.

[Updated on: Mon, 11 March 2013 13:37]

Report message to a moderator

Re: Update / Refresh a TableField after an update / change [message #1017389 is a reply to message #1017284] Mon, 11 March 2013 18:17 Go to previous message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Henrique Meira wrote on Mon, 11 March 2013 14:37

p.s.: I'll pull the MCQS project, will be very useful.


I have pushed a version (Swing and SWT) that is compatible with Juno SR2 on the preview branch.

I do not have a lot documentation on this project (it was the base for my article: Premiers pas avec Eclipse Scout (in French) and my talk at Eclipse Day Paris 2011: Les possibilités d'Eclipse Scout)


Henrique Meira wrote on Mon, 11 March 2013 14:37

p.s2.: Do you know others (open) projects based on Eclipse Scout.


I have opened a page to reference the Eclipse Scout Demo Applications. It is a work in progress!
Previous Topic:Making AbstractDrawLineField persistent
Next Topic:AbstractPageWithTree
Goto Forum:
  


Current Time: Wed Apr 24 15:50:07 GMT 2024

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

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

Back to the top