Convert list from java to dropdown menu in html

I have an output from java code as a list

public class getProjectList {
    final String username = "username";
    final String password = "password";
    final String ProjectNames = null;

    public getProjectList() throws URISyntaxException, InterruptedException, ExecutionException {
        final URI jiraserverURI = new URI("https://jira.xxxx.com");
        final JiraRestClientFactory restClientfactory = new AsynchronousJiraRestClientFactory();
        final JiraRestClient restClient =
          restClientfactory.createWithBasicHttpAuthentication(jiraserverURI,username,password);
        final Iterable<BasicProject> allproject = restClient.getProjectClient().getAllProjects().get();
        final String ProjectNames = allproject.toString();
        System.out.println(ProjectNames);
    }
}

      

I want to use the output from this code as a dropdown menu. Need help with this. Thank you.

+3


source to share


1 answer


String projectsToHtmlOptions(String projectNames,String separator){
   StringBuilder sb = new StringBuilder();
   sb.append("<select>");
   for(String project:projectNames.split(separator)
      sb.append("<option value=\""+project+"\">"+project+"</option>");
   sb.append("</select>");
   return sb.toString();
}

      



+1


source







All Articles