content management system - AEM6, json drop-down: want to populate only value in drop down and not text -


i have json structure follows: [{"text":"us","value":"united sates"},{"text":"ca","value":"canada"}]

i have created servlet populate dropdown component. servlet:

           while (node.hasnext()) {             node child = node.nextnode();             if (child.hasproperty("nationcode") && child.hasproperty("nationname")) {                 jsonobject json = new jsonobject();                 json.put("text", child.getproperty("nationcode").getvalue().getstring());                 json.put("value", child.getproperty("nationname").getvalue().getstring());                 jsonarray.put(json);             }         } 

response.setcontenttype("application/json"); response.getwriter().write(jsonarray.tostring());

my component has options="bin/"

i try populate value populate "text" in drop down. how make sure component drop-down populates values not keys(text) ?

i had implemented similar approach , remember rendering format showed did not work. think pulled format geometrixx uses in dropdown (not sure of exact path)

the json format used response was

[{"text":"us","value":"united states","qtip":""}, {"text":"ca","value":"canada","qtip":""}] 

once had list of required details used below rendering required json format

for (object object : allobjects) {                     (int = 0; < 3; i++) {                         jsonout.put("qtip", "");                         jsonout.put("text", object.gettitle());                         jsonout.put("value", object.getdescription());                         response.setcontenttype("application/json");                         response.setcharacterencoding("utf-8");                         log.debug("jsonout {}", jsonout);                     }                     } 

that worked me.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -