The goal is to properly get SelectItem.value and set it in my backing bean. The problem is itemValue seems to return only the object reference . I just followed reference this https://www.primefaces.org/showcase/ui/input/oneMenu.xhtml
How do you actually get the object (which is the itemValue) of the selected item?
Tried to have the setter as the exact Object my itemValue is but that ends up setting null as the value
Tried to have the setter as a general Object and it results to setting the value as the object reference as String
<p:selectOneMenu id="car" value="#{selectOneMenuView.car}">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{selectOneMenuView.cars}" />
</p:selectOneMenu>
Backing bean
Car car = new Car(brand, model);
SelectItemGroup g1 = new SelectItemGroup("German Cars");
g1.setSelectItems(new SelectItem[] {new SelectItem(car, "BMW")});
Car car1 = new Car(brand1, model1);
SelectItemGroup g2 = new SelectItemGroup("American Cars");
g2.setSelectItems(new SelectItem[] {new SelectItem(car1, "Chrysler")});
cars = new ArrayList<SelectItem>();
cars.add(g1);
cars.add(g2);
When there's an item selected, setCar is invoked but it seems to not pass the value that I want.
//value is null
public void setCar(Car car) {this.car = car;}
//value is the object reference
public void setCar(Object car) {this.car = car;}
I've tried explicitly putting the var and itemValue property but still the same results.
I can't seem to find a good documentation for this. Is my goal possible? I need some help. Thanks!