users@javaserverfaces.java.net

converters and the selectManyListbox

From: Dave Sag <dsag_at_visualitylife.com>
Date: Tue, 26 Oct 2004 17:59:18 +0200

Hi people,

I am having a small issue with my use of a custom converter and the
selectManyListbox. Allow me to explain:

I have a Permission object and a Role object. The Role has a String
name and a Collection of Permissions. All of these objects are
persisted to the database using JDO.

I have written a custom Converter 'permissionConverter' that converts
between a Permission and its JDO-supplied id string.

I want to display to the user a pick list of the permission names, but
the values of course should be the JDO ids.

Here is my JSF code:
<h:selectManyListbox id="permissions"
         value="#{roleHandler.fields['permissions']}"
       (1)
         converter="permissionConverter">
          (2)
     <f:selectItems value="#{roleHandler.allPermissions}"/> (3)
</h:selectManyListbox>

(1) - the roleHandler contains a Map of fields. The permissions
referenced there is a list of the role's actual Permissions objects. I
was assuming the converter would convert these to ids, and thus know
what to select.

(2) - the converter converts between permissions and the strings of
their ids.

(3) roleHandler.allPermissions returns a Map of the permissions'
id-strings and names.

the approx html i was expecting is
<select id="blahblah..permissions" name="blahblah..permissions"
multiple="multiple">
     <option value="8767766-99">perm1</option>
    <option value="8767766-97" selected="true">perm 2</option>
...
</select>

can anyone see anything obvious i may have done?



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
For additional commands, e-mail: users-help_at_javaserverfaces.dev.java.net