Created
August 23, 2017 05:18
-
-
Save darbyluv2code/0f80e35bd1cb5a6bb88a17e550a9f6b8 to your computer and use it in GitHub Desktop.
JSF - drop-down lists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.luv2code.jsf.hello; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import javax.faces.bean.ManagedBean; | |
| @ManagedBean | |
| public class StudentTwo { | |
| private String firstName; | |
| private String lastName; | |
| private String country; | |
| // list of countries for the drop-down list | |
| List<String> countryOptions; | |
| // no-arg constructor | |
| public StudentTwo() { | |
| // populate the list of countries | |
| countryOptions = new ArrayList<>(); | |
| countryOptions.add("Brazil"); | |
| countryOptions.add("France"); | |
| countryOptions.add("Germany"); | |
| countryOptions.add("India"); | |
| countryOptions.add("Turkey"); | |
| countryOptions.add("United Kingdom"); | |
| countryOptions.add("United States"); | |
| } | |
| // getter/setter methods | |
| // need to add a getter method for country options | |
| public List<String> getCountryOptions() { | |
| return countryOptions; | |
| } | |
| public String getFirstName() { | |
| return firstName; | |
| } | |
| public void setFirstName(String firstName) { | |
| this.firstName = firstName; | |
| } | |
| public String getLastName() { | |
| return lastName; | |
| } | |
| public void setLastName(String lastName) { | |
| this.lastName = lastName; | |
| } | |
| public String getCountry() { | |
| return country; | |
| } | |
| public void setCountry(String country) { | |
| this.country = country; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment