Now that we have the basic framework of our filter we need to add our choices. The filter can be described as a set of options and a set of selections, which are a subset of the options. Collectively we refer to these as the 'choices'. As we are using the ChoiceRenderer to create the drop-down list, so we can use the ChoiceBuilder to create the content that we pass to the ChoiceRenderer. The ChoiceBuilder accepts a HashMap which is the set of id's and values. In our case the values will be the list of genres that we display in the drop down. In this simple example we use the lower case version of the value as the id.
018 HashMap<String, String> genres = new HashMap<String, String>(); 019 genres.put("all", "- All -"); 020 genres.put("horror", "Horror"); 021 genres.put("drama", "Drama"); 022 genres.put("romance", "Romance"); 023 genres.put("comedy", "Comedy"); 024 genres.put("action", "Action"); 025 026 // Create the options and selections using the ChoiceBuilder. 027 ChoiceBuilder choices = 028 ChoiceBuilder.newInstance(genres, document);