Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Java SelectOneMenu Help

  • 07-04-2008 11:01am
    #1
    Registered Users, Registered Users 2 Posts: 18,272 ✭✭✭✭


    need help with a java selectonemenu, I am designing a car site where I want to search by car make car model and year, so i have 3 selectonemenus on the page, I want the second menu to adjust itself to what is selected in the first menu so if honda is selected then all the honda models in the database are displayed.

    here is my bean code:
    public class searchBean {


    private String make;
    private String models;
    private String Year;
    private boolean makeSelected;

    private ArrayList<SelectItem> makeItems = null;
    private List<SelectItem> modelItems = null;
    private List<SelectItem> yearItems = null;

    public void setMake(String makes) {
    this.make = makes;
    }

    public String getMake() {
    return make;
    }

    public void setMakeItems(ArrayList<SelectItem> makeItems) {
    this.makeItems = makeItems;
    }

    public List<SelectItem> getMakeItems() {
    return makeItems;
    }

    public searchBean() throws DaoException {

    CarsDao dao = new CarsDao() ;



    /*
    * See selectOneMenu above. Fill ArrayList<SelectItem> from database
    */
    List<String> makes = dao.findAllMakes() ;
    makeItems = new ArrayList<SelectItem>() ;
    for (String make : makes) {
    makeItems.add(new SelectItem(make) ) ;
    }

    //String selectedMake = makeItems.;
    List<String> models = dao.findAllModels("Honda") ;
    modelItems = new ArrayList<SelectItem>() ;
    for (String model : models) {
    modelItems.add(new SelectItem(model) ) ;
    }

    List<String> years = dao.findAllYears() ;
    yearItems = new ArrayList<SelectItem>() ;
    for (String year : years) {
    yearItems.add(new SelectItem(year) ) ;
    }
    /*
    * See selectOneListbox above. Fill ArrayList<SelectItem> from database
    */


    }

    public void setModels(String models) {
    this.models = models;
    }

    public String getModels() {
    return models;
    }

    public void setModelItems(List<SelectItem> modelItems) {
    this.modelItems = modelItems;
    }

    public List<SelectItem> getModelItems() {
    return modelItems;
    }

    public void setYear(String year) {
    this.Year = year;
    }

    public String getYear() {
    return Year;
    }

    public void setYearItems(List<SelectItem> yearItems) {
    this.yearItems = yearItems;
    }

    public List<SelectItem> getYearItems() {
    return yearItems;
    }


    }


    List<String> models = dao.findAllModels("Honda") ;

    I have "Honda" in there and it works like that hardcoded, I have tried using the variable make in there but this doesn't work the menu just comes up blank.

    So I want the user to be able to select whatever model from the first menu and then the models will show up according to that selection, I have found a way to do it where it will bring up on item, but cant seem to find out how to do it as a list, so i would have a list of models in the menu.

    any help greatly appreciatted


Advertisement