Home » Eclipse Projects » Eclipse Scout » Populating smartfields and list boxes from a JSON document(Beginner question: populating smartfields and listboxes from a JSON document)
Populating smartfields and list boxes from a JSON document [message #1849990] |
Thu, 10 February 2022 07:40  |
Eclipse User |
|
|
|
Hello there everyone,
Whenever forms are loaded in my Scout application, I want the form's smartfields and listboxes to be populated with data retrieved from a remote REST server.
For example, I have the JSON document below:
[
{
"resultat": {
"resource": "/genre",
"genre": [
{
"numero": 1,
"description": "Feminin"
},
{
"numero": 2,
"description": "Masculin"
},
{
"numero": 3,
"description": "X"
}
]
}
},
{
"resultat": {
"resource": "/typepartenaire",
"type_partenaire": [
{
"numero": 1,
"description": "Association"
},
{
"numero": 2,
"description": "Autre"
},
{
"numero": 3,
"description": "Conscription"
},
{
"numero": 7,
"description": "Employeur public (non-marchande)"
},
{
"numero": 4,
"description": "Entreprise (marchande)"
},
{
"numero": 5,
"description": "Formateur"
},
{
"numero": 6,
"description": "Hôpital"
}
]
}
},
{
"resultat": {
"resource": "/typepartenairecontact",
"type_partenaire_contact": [
{
"numero": 10,
"description": "Administratif"
},
{
"numero": 2,
"description": "Assistante Sociale"
},
{
"numero": 7,
"description": "Autres Travailleurs Associatif"
},
{
"numero": 3,
"description": "Autres Travailleurs Sociaux"
},
{
"numero": 4,
"description": "Bénévoles"
},
{
"numero": 5,
"description": "Juriste"
},
{
"numero": 1,
"description": "Médiateur"
},
{
"numero": 11,
"description": "Politique"
},
{
"numero": 6,
"description": "Soignants"
},
{
"numero": 9,
"description": "Écrivaine Public"
},
{
"numero": 8,
"description": "Éducateur"
}
]
}
}
]
The form's smartfields and listboxes present a standard textual data and reduces the risk of misspellings. At the back end, what is stored in the database is the numeric code corresponding to the description labels in the JSON document above. so the user selects a certain text BUT the text's number will be saved in the database.
In the document above, there are 3 types of resources: genre, type_partenaire and type_partenaire_contact. Each one of these resources will have its own smartfield/listbox on the form.
Can anyone please help me with ideas on how to load and present the data above in smartfields ond listboxes?
Thanks a million,
JD
|
|
| | | | |
Re: Populating smartfields and list boxes from a JSON document [message #1850521 is a reply to message #1850516] |
Mon, 07 March 2022 09:35  |
Eclipse User |
|
|
|
J D wrote on Mon, 07 March 2022 14:00Hi there Andre,
Thanks a lot for the tips. I've had to do a lot of refactoring and reading the Scout documentation again.
Thus far, I've gotten the SmartFields and ListBoxes in my application to work. I have tended to retrieve the information I need when forms are being initialized, and then use a LocalLookupCall to populate the widgets successfully. I however notice a little lag when loading a form that has many SmartFields; for example, I have a form with about 35 SmartFields and Listboxes. The lag is not a major problem but I may have to resort to fetching information from the Server directly into the widgets for some other forms.
I have 2 questions:
a) will using threads in execCreateLookupRows() and the various getDataXXX functions speed up the process?
b) how do I create SmartFields and ListBoxes with Tree based content?
Thanks a million,
JD
|
|
|
Goto Forum:
Current Time: Fri Jun 13 15:12:27 EDT 2025
Powered by FUDForum. Page generated in 0.06320 seconds
|