ListMultiplyChoice expects a Collection not an Array as the model object
Else it doesnt know how to fill it (currently)

public ListMultipleChoice(final String id, IModel<Collection<T>> object,
final List<T> choices)

so change this:

...
       public void setPermissions(Authority[] permissions) {
               this.permissions = permissions;
       }
       public Authority[] getPermissions() {
               return permissions;
       }

to a collection.

On Fri, Apr 25, 2008 at 10:37 PM, Ronald Pieterse <[EMAIL PROTECTED]>
wrote:

>
> Hello.
>
> I an trying to use the ListMultipleChoice and want to use my list of
> custom
> Authority object as options. The form is shown correctly with the right
> options and values and everything.
> The problem arises when I submit the form. For some reason the selected
> values are not converted correctly to the array of Authority objects that
> I
> defined in my User class.
>
> The message I get is:
>
> WicketMessage: Can't convert value: [ROLE_ADMIN, ROLE_ADVANCED, ROLE_USER]
> to class: class [Lcom.tripolis.common.domain.security.Authority; for
> setting
> it on (object's toString() method value)
>
> I tried various convert methods and implementing an IConverter in the
> getConverter method but nothing worked. Can someone let me in on the big
> secret here?
>
> My User class is:
>
>        private Authority[] permissions;
>        ...
>        public void setPermissions(Authority[] permissions) {
>                this.permissions = permissions;
>        }
>        public Authority[] getPermissions() {
>                return permissions;
>        }
>
>
> My form is:
>
>        ListMultipleChoice dropdown = new
> AuthorityListMultipleChoice("permissions",
>
>  Authority.findRolesBySecurityLevels(Authority.SECURITYLEVEL_PARTNER,
> Authority.SECURITYLEVEL_APPLICATION, Authority.SECURITYLEVEL_API)
>        );
>        add(dropdown);
>        dropdown.setRequired(true);
>        ...
>        // inner class
>        private final class AuthorityListMultipleChoice extends
> ListMultipleChoice
> {
>
>                public AuthorityListMultipleChoice(String id,
> List<Authority> authorities)
> {
>                        super(id, authorities, new ChoiceRenderer() {
>                                @Override
>                                public Object getDisplayValue(Object
> object) {
>                                         return ((Authority)
> object).getAuthority(); // returns the string
> value
>                                }
>
>                                @Override
>                                public String getIdValue(Object object, int
> index) {
>                                         return ((Authority)
> object).getAuthority(); // returns the string
> value
>                                }
>                        });
>                }
>        }
> --
> View this message in context:
> http://www.nabble.com/Problem-converting-options-of-ListMultipleChoice-tp16905157p16905157.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to