4 Replies Latest reply on May 3, 2013 2:07 AM by vijayanandvinju

    How to populate a drop down from an external source say an excel sheet?

    Shradheya

      Hi ,

      I want to retrieve data from an external excel sheet to populate a drop down..how can i proceed?

        • 1. Re: How to populate a drop down from an external source say an excel sheet?
          Yadav Brijesh Level 1

          Hi,

           

          Parse the data from xml using JAXB parser and put in a java bean. Now return json object which contains key values pairs for populating the values in drop down. You can refer list component for the Response json format.

           

          Regards

          Brijesh

          • 2. Re: How to populate a drop down from an external source say an excel sheet?
            rush_pawan Level 4

            And if you want it to populate in dialog dropdown then the file should exist in system and configure the "selection" xtype as below

             

            <metadata

                jcr:primaryType="cq:Widget"

                fieldDescription="some description of the field"

                fieldLabel="field label"

                name="./dropdown"

                options="<jason file path>"

                type="select"

                xtype="selection"/>

             

            and your options.json file should have following structure:

             

            [

              {"value" : "String","text" : "String"},

              {"value" : "Long","text" : "Number"}

            ]

            • 3. Re: How to populate a drop down from an external source say an excel sheet?
              vishnu_reddy357

              Hi,

              I have the similar requirement as mentioned aboev to populate a list of values in dialog dropdown. I ahve few doubts reagarding this.

              1) How should i create a static json file which contains my dropdown values?

              2) Where should i place my options.json file and how do i refer it in dialog?

              3) Apart from "options" property, should i need to add any other property?

               

              The following is the way that i have already tried out but facing some issues.

              I have created a servlet(service) for retrieving options, where in i have written something like below.

               

              JSONWriter writer = new JSONWriter(response.getWriter());

               

              writer.array();

                         

                          writer.object();

                          writer.key("text").value("random");

                          writer.endObject();

               

                          writer.object();

                          writer.key("text").value("simpleFade");

                          writer.endObject();

              writer.endArray();

               

              options: "/bin/slideshow/options"

               

              also i am using the same value in the servletpath.

               

              I am able to get the values in the dropdown in dialog but i am unable to retreve them in my jsp.

              Do  i need set anyother propety to my widget?

              Can someone help with the cause/solution or any better approach is really appreciable.

               

              thanks,

              vishnu

              • 4. Re: How to populate a drop down from an external source say an excel sheet?
                vijayanandvinju

                Any node in JCR has its default renderer for json, infinity.json, pdf, html etc. We can take advantage of this to read a property of the node as JSON format.

                 

                Example: marketing tags can be populated in a dropdown by setting the "options" property to point to "/etc/tags/marketing/interest.infinity.json". Hope this helps in this context?