Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert List from java to a dropdown menu in html

I have output from a java code in the form of 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 item. Need help with this. Thank You

like image 211
Kandarp Gandhi Avatar asked Feb 20 '26 22:02

Kandarp Gandhi


1 Answers

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();
}
like image 129
Seppo420 Avatar answered Feb 23 '26 11:02

Seppo420



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!