Reusing the same formData member on more than one field [message #975956] |
Thu, 08 November 2012 07:51 |
Urs Beeli Messages: 573 Registered: October 2012 Location: Bern, Switzerland |
Senior Member |
|
|
I have a form containing two tabs. One tab shows a rough overview over the data returned (company name, the year for which the data is shown, a total over the data) while the second tab shows the detail data but it also includes some "header" data (the year for which the data is shown, the total).
When I try to create two fields with the same name on the different tabs (i.e. in their group boxes) Scout complains, telling me the name already exists. If I rename the field, an additional member with the new name is added to the formData.
I currently solve this, by returning the data twice in my process service, i.e.
SQL.selectInto("select name, year, year, total, total, n1, n2, ... nN" +
"from company where company_nr = :companyNr" +
"into :companyName, :year, :year2, :total, :total2, :n1, ... :nN",
formData);
This works, but seems to me to be a clumsy way of solving this issue. Is there a workaround for this?
|
|
|
|
Re: Reusing the same formData member on more than one field [message #980824 is a reply to message #980578] |
Mon, 12 November 2012 01:12 |
|
Hello Bertin,
I am not quite sure that i understand how to do it.
Till now i am using the following quidelines in order to include a field in an IForm or IFormField.
- For every field i have to create an inner class implementing the IFormField.
- The order of appearance can be controlled by @Order annotation.
Is there another way to include a field?
|
|
|
|
|
|
|
|
Re: Reusing the same formData member on more than one field [message #990022 is a reply to message #987873] |
Mon, 10 December 2012 14:24 |
Urs Beeli Messages: 573 Registered: October 2012 Location: Bern, Switzerland |
Senior Member |
|
|
Actually, having played around with this some more, it seems that the solution suggested by Stephan doesn't work after all (or at least not for all situations).
It does work for the "year1" and "year2" cases. However, when I tried to copy it for another field "total1" and "total2" it fails to work. I debugged it, and what happens is the following:
- total1 is set as part of the importFormData() call
- this triggers both the propertyChange() call and the importFormFieldData() call which copies the total1Field value to total2Field
However, now importFormData() continues, and as my processService did not fill total2 on the form field, importFormData() now overwrites my (propagated and correct) total2Field value with the total2 member of the formData (which is null), so once my form is shown, the corresponding field is empty again
I guess it makes more sense to use the method proposed by Lukas for the inital population of the form and use the propertyChange listener to propagate changing values during the life time of the form. As it looks now, I can probably forgo overwrite importFieldData().
I'm not quite sure why the same thing works with year1 and year2 (though things are slightly different as there is also a variable year which comes into this, so that might explain it).
Any comments on this?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07634 seconds