i'm learning JSF and beans.
I've the following code:
public class Example {
private List<ExampleObject> listExampleObject;
//Get and set from list...
}
public class ExampleObject extends ExampleObjectExtend {
private String exampleAttribute;
//Get and set from attribute.
}
public class ExampleObjectExtend {
private String extendedAttribute;
//Get and set from extendedAttribute..
}
I need to display a selectList with itemLabel=exampleAttribute and itemValue=extendedAttribute.
I did the following:
<h:selectOneMenu id="listExample">
<f:selectItems value="#{myBean.listExampleObject}" var="example" itemValue="#{example.extendedAttribute}" itemLabel="#{example.exampleAttribute}"/>
</h:selectOneMenu>
The point is that the itemLabel is being shown properly, but the value attribute from the option control is being shown as like this: com.package.example.web.Example@5a05a935 (i check this value by chrome debugger and firebug)
Why could this happen?
Thank you
UPDATE: I've implemented the provided solution by Jitesh and the system now works. Thank you so much!