Announcement Announcement Module
No announcement yet.
Converter not called? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Converter not called?


    I have a problem that I can't figure out. I have a flow that is suppose to register a new user with but for some reason the authorities doesn't get the correct type.

    The user:
    public class CustomUser implements Serializable, UserDetails {
        private List<Role> roles = new ArrayList<Role>();
        public Role[] getAuthorities() {
            return roles.toArray(new Role[0]);
        public List<Role> getRoles() {
            return roles;
        public void setRoles(List<Role> roles) {
            this.roles = roles;
    The Role:
    public class Role implements GrantedAuthority, Serializable {
        private String authority;
        public String getAuthority() {
            return authority;
        public void setAuthority(String authority) {
            this.authority = authority;
        public int compareTo(Object o) {
            return 0;
        public String toString() {
            return authority;
    The converter:
    public class StringToRole extends StringToObject implements Serializable {
        private RoleService service;
        public RoleService getService() {
            return service;
        public void setService(RoleService service) {
            this.service = service;
        protected Object toObject(String string, Class targetClass) throws Exception {
            return service.getRole(string);
        protected String toString(Object object) throws Exception {
            Role role = (Role) object;
            return role.toString();
        public StringToRole() {
    This works fine when reading the user and roles in the flow but when I try to save it to the database somehow the CustomUser.getRoles returns an ArrayList of Strings.

    Anyone know why that is?

    Best regards

  • #2
    maybe this one helps...

    Is this what you meant?->


    • #3
      I'm not sure what you mean?

      I believe my problem is that the method toObject isn't called when trying to go back to my domain model. But since I'm clueless to why it isn't I'm open to any suggestions on how to fix my problem.