Hey folks,
In HTML I can use the following for a dropdown:
Volvo
Saab
Mercedes
Audi
On submit, the database would store the value rather than the text.
I want to pull data from my database and use the value/data in a dropdown list. Pulling the data from the DB is easy, I have that now as a list. But how do I assign the list to a form dropdown and tell bonita that whatever option is selected to use the ‘value’ rather than the ‘text’?
I think that to do that you can use a HashMap or similar Collection item.
In the HashMap there is a key/value system so you can display only the key list and when you submit the form, you get the value corresponding to the selected key.
To create the Hashmap :
HashMap<String,String> hashmap = new HashMap<String,String>();
// for each Data, you add it in the hashmap
hashmap.put(key,value);
Then in the widget you can get the key list with :
So, when I use the connector to get the data, it does not allow me to use hashmap.
It does allow me to use HashMappedList.
If I create a java.hashmap variable in the connector, once created, it does not show in the list to use in result. But, HashMappedList does. Is that ok to use?
HashMap<String,String> hm= new HashMap<String,String>();
resultset.beforeFirst();
while (resultset.next()) {
String key = resultset.getString(‘myKey’);
String value = resultset.getString(‘myValue’);
hm.put(key,value);
}
return hm;
For example in a table ‘CAR’ I have a column ‘name’ and a column ‘description’. I want to have all the car’s names in the list and when I submit the form, I get the description of the car I select.
My sql query is “SELECT * FROM CAR”.
In the script I have :
String key = resultset.getString(‘name’);
String value = resultset.getString(‘description’);
My hasmap is called ‘myHashMP’. My select is called ‘myDropdown’ So, I am doing:
retrun myHashMP.get(myDropdown)
This should be returning the id from the value. So I have set the return type to integer. I am selecting a integer variable in the pool ‘theId’ as ‘Output Operation’.
My next form uses ‘theId’ as data in a text so that I can check it, but no data is shown. Any idea?
Bonitasoft empowers development teams with Bonita, the open-source and extensible platform to solve the most demanding process automation use cases. The Bonita platform accelerates delivery of complex applications with clear separation between capabilities for visual programming and for coding. Bonita integrates with existing solutions, orchestrates heterogeneous systems, and provides deep visibility into processes across the organization.