0
votes

I've only been using Ice:faces for a week now and I'm having problems figuring out how to implement a simple selectOneMenu to my page so I can select a gender of a person by a simple drop down rather then typing stuff in.

The error im getting is the following


type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.el.MethodNotFoundException: Method not found: [email protected](javax.faces.event.ValueChangeEvent)

note The full stack traces of the exception and its root causes are available in the Sun GlassFish Enterprise Server v2.1.1 logs.


so i figured im obviously refering to something that isnt there

here is my code

In the page jsp form :

<ice:selectOneMenu valueChangeListener="#{homeSelect.selectedGender}">
    <f:selectItems value="#{homeSelect.genders}"/>
</ice:selectOneMenu>

the class for the select menu :

import java.util.LinkedList;
import java.util.List;

import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;


public class SelectMenuHomes
{
    public static String selectedGender = null;


    public static void changeGender(ValueChangeEvent event)
    {
    selectedGender = event.getNewValue().toString();
    }

    public List<SelectItem> getGenders()
    {
        List<SelectItem> genderList = new LinkedList<SelectItem>();
        genderList.add(new SelectItem("Male"));
        genderList.add(new SelectItem("Female"));
        return genderList;
    }


    public String getSelectedGender() {
        return selectedGender;
    }

    public void setSelectedGender(String selectedGender) {
        this.selectedGender = selectedGender;
    }

}

and homeSelect is the name for the managed bean I gave to refer to the MenuSelectHomesClass

thank you for any help

2

2 Answers

0
votes

Solved

<ice:selectOneMenu value="#{dataControl.appendGender}"> 
<f:selectItems value= "#{homeSelect.genders}"/> 
</ice:selectOneMenu> 

appendGender is the variable used in the method to run the SQL query along with variables like appendName appendSurname etc etc

0
votes

you are missing the method called by the valueChangedListener. valueChangeListener="#{homeSelect.selectedGender}" in your jsf file points to a method "selectedGender(javax.faces.event.ValueChangeEvent)" in your homeSelect bean which is missing. You are not using the value= attribute.

You cant put objects directly in these menus without a converter or utility.

see "Use Objects in selectMenu": http://balusc.blogspot.ch/2007/09/objects-in-hselectonemenu.html also have a look at: http://omnifaces.org which comes along with such a converter.