Error in select item value binding
my classes are as follow
ArrayList typeList;// list of Type
class Type{
Component component;
// other attributes
}
class Component{
String name;
String value;
// other attributes
}
i want to bind component name/value to select item.
i use the following code but i got exception.
<h:selectOneMenu>
<f:selectItems value="#{selectitems.typeList.component.name.component.value.toArray}" />
</h:selectOneMenu>
javax.faces.el.EvaluationException: javax.faces.el.ReferenceSyntaxException: The"." operator was supplied with an index value of type"java.lang.String" to be applied to a List or array, but that value cannot be converted to an integer.
is there any way to solve this problem?
thanks and regards
terence
[1190 byte] By [
mtzo81a] at [2007-11-27 6:39:57]

# 2
hi BalusC
thanks for your reply
i think it is not necessay to be a collection SelectItem object to bind to f:selectItems
the following code works for me without any problem
ArrayList componentList; // list of Component
<h:selectOneMenu>
<f:selectItems value="#{selectitems.componentList.name.value.toArray}" />
</h:selectOneMenu>
it only happens when a bean is inside another bean.
do u have any solution?
thanks and regards
terence
# 3
> my classes are as follow
>
> > ArrayList typeList; // list of Type
>
> class Type {
>Component component;
> // other attributes
> }
>
> class Component {
>String name;
> String value;
>// other attributes
> /code]
>
> i want to bind component name/value to select item.
> i use the following code but i got exception.
>
> [code]
> <h:selectOneMenu>
> <f:selectItems
> value="#{selectitems.typeList.component.name.component
> .value.toArray}" />
> </h:selectOneMenu>
>
>
> > javax.faces.el.EvaluationException:
> javax.faces.el.ReferenceSyntaxException: The "."
> operator was supplied with an index value of type
> "java.lang.String" to be applied to a List or array,
> but that value cannot be converted to an integer.
>
It looks to me that the EL evaluating is failing on the "typeList.component" portion. "selectItems.typeList" is a List, and List has no getComponent() method, so the evaluator tries to use "component" as an index into the List and understandably fails.
# 4
if it is so, why this code work?
#{selectitems.componentList.name.value.toArray}
selectItem.componentList is a collection.
and it does not have getName method.
i'm quite blur on JSF EL........
regards
terence