Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Form with table and detail fields(Form with table and detail fields)
Form with table and detail fields [message #783791] Thu, 26 January 2012 08:21 Go to next message
Bertin Kiekebosch is currently offline Bertin Kiekebosch
Messages: 280
Registered: August 2011
Senior Member
Hi,

I have to create a form with on top of the form a table. Below the table some fields, that show details of the selected item in the list.

In this way the user can quickly see the details of the items wiyhout opening a secondary form. (There are too many details (long strings) to show them all as columns in the list)

It should also be possible to create new items, edit them and delete them.

Can I create such a form with scout components and if yes is there any example.

Regards Bertin
Re: Form with table and detail fields [message #783845 is a reply to message #783791] Thu, 26 January 2012 10:24 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 529
Registered: October 2011
Senior Member
I can recommend you to have a look at this case:

The QuestionForm contains a TableField that holds choices (see QuestionsListForm.MainBox.QuestionsField line 118).
There is only 2 columns, but you could have more (also some that are not visible / displayable).
The edition is realized in another form (ChoiceForm), but it does not matter. This ChoiceForm do not have any ProcessService, the EditHandler (FormHandler of this form) does nothing. Instead of this form, the fields could be in a GroupBox in the QuestionForm.

Persistence only takes place server-side when the QuestionForm is sent. (QuestionProcessService line 100)

I hope you get the idea.
Re: Form with table and detail fields [message #783856 is a reply to message #783845] Thu, 26 January 2012 10:42 Go to previous messageGo to next message
Bertin Kiekebosch is currently offline Bertin Kiekebosch
Messages: 280
Registered: August 2011
Senior Member
Yes I get the idea,

I was wondering if I could hook up the fields with a column in a way that when the user selects a row, the value of the current row would be visible in the fields. As I understand from the example, I should do that myself.

So on row select, copy all the values to the fields
If a field value is changed, copy it back to the row.

At the end when the user hits the OK button, save the whole tableField with the use of a process service.

Is that the idea?

Re: Form with table and detail fields [message #783942 is a reply to message #783856] Thu, 26 January 2012 14:48 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 117
Registered: November 2010
Senior Member
Now that you mention it, it is possible to write some Utilitiy / Helper class... It is possible to work with AbstractClass or to use FindFieldByClass or FindColumnByClass...

To my mind, it is a good idea it if you plan to apply this pattern across multiple forms / tables. I am not sure that it is something that should be part of the framework, because it can be considered as application specific. The limit between what belongs to a framework and what not is not simple to define.

If you want to create a MapperHelper. Here some ideas:
- instantiate the class Mapper in the ini in the table.
- the helper should provide a method "<T> bind([column class_or_instance type T], [field class or instance type T])" to create a pair
- keep a pointer on the instance in the table.
- at initialization register a value changed listener on each field.
- in the table when you want (with a menu, or when selection changed) call an update method on the mapper. In this method foreach pair (Column, Field), copy the value from the column in the field (ignore value changed)
- when the value changed (by some user input) in one of the field, copy the new value back in the column.

You also need to handle enable state of the fields.
I think that the field should not trigger a "save is needed" -> set the property to false.
The table field should handle if save is needed or not.

If you have mandatory attribute, you also need to take this into account.

.
Re: Form with table and detail fields [message #783947 is a reply to message #783942] Thu, 26 January 2012 15:04 Go to previous messageGo to next message
Bertin Kiekebosch is currently offline Bertin Kiekebosch
Messages: 280
Registered: August 2011
Senior Member
Thanks for the homework Smile, I will give it a try.
Re: Form with table and detail fields [message #785073 is a reply to message #783942] Sat, 28 January 2012 07:18 Go to previous messageGo to next message
Bertin Kiekebosch is currently offline Bertin Kiekebosch
Messages: 280
Registered: August 2011
Senior Member
Hi Jerimie,

I have something up and running but there are some issues.

I bind to AbstractValueField, on abstract value field, I can only find a addPropertyChangeListener. Did you mean this with "- at initialization register a value changed listener on each field." or do I have to use something else.

The addPropertyChangeListener does not fire always at the moment I want to, unless I check Validate On Any Key. The nice thing with that is, that the value in the column is directly synchronised when you type. (Some columns are visible others not, but it is a nice effect). So the value is directly stored in the column, this makes saving it a little easier.

I have some problems with validation. What I want is to disable some actions as long as the values in the fields are not valid. Suppose a new record is added with three mandatory fields. As long as all the fields do not have a valid value, the user should not be able to switch rows, add another row etc. and it would be nice to have some visiual feebback that indicates which fields are not valid yet.

Regards Bertin

Re: Form with table and detail fields [message #786006 is a reply to message #785073] Sun, 29 January 2012 16:53 Go to previous message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 117
Registered: November 2010
Senior Member
Bertin Kiekebosch wrote on Sat, 28 January 2012 13:18
I bind to AbstractValueField, on abstract value field, I can only find a addPropertyChangeListener. Did you mean this with "- at initialization register a value changed listener on each field." or do I have to use something else.

The addPropertyChangeListener does not fire always at the moment I want to, unless I check Validate On Any Key. The nice thing with that is, that the value in the column is directly synchronised when you type. (Some columns are visible others not, but it is a nice effect). So the value is directly stored in the column, this makes saving it a little easier.


I was sure there is a the possibility to register a listener that is notified when the value of a field changed... I need to check how.

PropertyChangeListener is for synchronization between the Scout Model and the UI rendering Plug-in. I was not thinking of this...

I will have a look in the code...


Bertin Kiekebosch wrote on Sat, 28 January 2012 13:18
I have some problems with validation. What I want is to disable some actions as long as the values in the fields are not valid. Suppose a new record is added with three mandatory fields. As long as all the fields do not have a valid value, the user should not be able to switch rows, add another row etc. and it would be nice to have some visiual feebback that indicates which fields are not valid yet.


For User Notification you can use: setErrorStatus(..) and clearErrorStatus() on any field... You have different level: info, warning, error...

In order to block invalid state, you can disable the table. Or you can add a "Save" button that copy the values of you field back in the table. It depends of what user experience you want.
Previous Topic:Server /process HTML page
Next Topic:Start application with parameters
Goto Forum:
  


Current Time: Sun Apr 20 15:54:23 EDT 2014

Powered by FUDForum. Page generated in 0.01833 seconds