Hi,

this component is a nice counterpart to returning back a list of
SelectItems in your model bean code.

So, what you actually need is a label and a value for each entry in
the list, which in turn is exactly the same as filling a list of
SelectItems.

You are right with your first try when writing
itemValue="#{Group.id}". The itemValue must be a unique identifier for
mapping the value to a group object after the response in order to
know which entry (or entries) has (have) been choosen.

So, the expected type given in the value field (selectedItems in your
case) has to be the same as the itemValue type. E.g. Group.id is a
Long, so selectedItems has to be of type Long[]. In case of a
SelectOne component it would be simply a Long.

Just generate setters and getters for the value field, and this should
do the trick.

Hope this helps,

cheers - Gerald

On 3/14/07, Wiebke Henrici <[EMAIL PROTECTED]> wrote:
Hi,

I want to use t:selectItems within a t:selectManyCheckbox. My problem is
that I always get a validation error saying that the value is not valid.

My JSP:
<t:selectManyCheckbox id="sensor_access"
value="#{sensorBacker.selectedItems}" layout="pageDirection"
layoutWidth="3">
<t:selectItems value="#{sensorBacker.groups}" var="Group"
itemLabel="#{Group.name}" itemValue="#{Group.id}" />
</t:selectManyCheckbox>

The definition of sensorBacker.selectedItems and sensorBacker.groups:
private Collection<GroupBean> groups;
private ArrayList<GroupBean> selectedItems = new ArrayList<GroupBean>();

When I load my JSP, I fill groups with:
groups = remoteReader.readAllGroups();
This works alright, there is one checkbox per group.

I am not really sure what to use as itemValue in the t:selectItems. I
tried with "Group", this didn't work either and gave the same error.
I tried with Group.name, this gave no validation error but a
ClassCastException in my backing when I tried to do a loop like that:

for (GroupBean group: selectedItems){
(some debugging output here)
}

Can anyone tell me what kind of value has to be there for itemValue? Or
what else am I doing wrong?

Wiebke



--
http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Reply via email to