Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
After reading the knowledge base article titled "Obtain data from external database"
I followed the instructions (added the select box and chose beanshell binder) and tried to populate the dropdown list with a FormRowSet object populated with FormRow objects using this code:
import org.joget.apps.form.model.*; public FormRowSet test() { FormRowSet f = new FormRowSet(); f.setMultiRow(true); FormRow r = new FormRow(); FormRow rr = new FormRow(); r.put("test1","tester1"); rr.put("test2","tester2"); f.add(r); f.add(rr); return f; } return test();
The code gets executed when I go to the preview pane, but when it renders I get a bunch of json and not the drop down in the form I'm expecting. In the log file I see this error:
Oct 10, 2011 3:51:13 PM org.joget.apps.form.service.FormService previewElement SEVERE: Error generating element html java.util.NoSuchElementException: Hashtable Enumerator at java.util.Hashtable$Enumerator.nextElement(Hashtable.java:1021) at java.util.Hashtable$Enumerator.next(Hashtable.java:1032) at org.joget.apps.form.service.FormUtil.getElementPropertyOptions(FormUtil.java:741) at org.joget.apps.form.lib.SelectBox.getOptionMap(SelectBox.java:38) at org.joget.apps.form.lib.SelectBox.renderTemplate(SelectBox.java:81) at org.joget.apps.form.model.Element.render(Element.java:167) at org.joget.apps.form.service.FormService.generateElementDesignerHtml(FormService.java:123) at org.joget.apps.form.service.FormService.previewElement(FormService.java:54) at org.joget.apps.form.service.FormService.previewElement(FormService.java:35) at org.joget.apps.app.controller.FormBuilderWebController.previewElement(FormBuilderWebController.java:118)
Another odd thing. When I modify the code portion to only add a single FormRow to the FormRowSet (only call f.add(r) and comment out f.add(rr)) it seems to work. The preview shows my form with a single item in the drop down list.
So. My question is what am I doing wrong and how do I populate the drop down with multiple items from beanshell?
Thanks,
Andrew
4 Comments
Andrew
This is with the BETA2 release of v3 if that makes a difference.
Owen Ong
Hi Andrew,
The correct way to doing it is as below:
Hope it's help.
Regards,
Owen
Andrew
That is exactly what I needed. Thank you!
Hafizuddin Husain
thanks too. really help.