|
|
|
Re: Form with table and detail fields [message #783942 is a reply to message #783856] |
Thu, 26 January 2012 19:48 |
Jeremie Bresson Messages: 124 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 #785073 is a reply to message #783942] |
Sat, 28 January 2012 12:18 |
Bertin Kiekebosch Messages: 330 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 21:53 |
Jeremie Bresson Messages: 124 Registered: November 2010 |
Senior Member |
|
|
Bertin Kiekebosch wrote on Sat, 28 January 2012 13:18I 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:18I 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.
|
|
|
Powered by
FUDForum. Page generated in 0.04405 seconds