I have one many-to-many relationship between Contest and Services. In the middle i have 2 classes: ContestServiceId, and ContestService.
I'm trying to make a webflow where, in one step, i can select (checboxes) which Services are involved in the Contest; but when i try to load that page i get this error:
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.String to type @javax.persistence.OneToMany java.util.Set
How can i make this converter?
I already did one converter for each single entity (eg. StringToContestConverter, useful, for example, for select).
I tried to do an empty converter (with no code inside because i don't know what i have to do with ids)
and i set a breakpoint... it never stop there...
Here the code used in my view that generate the error:
services_list is binded in the flow with:
Another try i did it was this:
but when i submit the form, i get validator error:
typeMismatch on contestServices
I tryed use Set, List, TreeSet, LinkedHashSet but nothing... If i have to change how to implement ManyToMany relationship may not be a problem... but i really need have this page where check which services are involved in contest...
It's not possible that i'm the first tryingo to do this...
thank you for any tips or suggestion.
posted 5 years ago
i'm looking for a Conversion Service or a Binding service, but still not have idea how to do it and use in webflow
posted 5 years ago
I found a solution. I don't think is the best but it works:
- in the view, i give a name to all checkboxes (chk_services, chk_agencies)
- on transition to the next step, i take the comma separated string generated from POST with the checked ids (id1, id2, ...) and i pass to a method
which split the string and, for each id, takes from db the related entity and put these in my Set of many-to-many entity (ContestService)
(i do this either when i go to the next step and to the previously step)
- on entry to the view, i want check again the checkboxes. to do this, i need to convert my Set<ContestService> to a list of ids:
- in the view, i see if check or no each checkbox with:
NOTE: '' + service_el.id is needed as without '' + it doesn't work
I post full code. i hope that someone will find it useful.
Any improvements and suggestion are welcome.
Webapp config (i'm using java annotation): configuration of the bean with methods used in the flow
ContestFlow bean with my methods:
View of the step 2: form with services checkboxes:
View of the step 3: form with agencies checkboxes:
finally: the flow xml configuration:
If I'd had more time, I would have written a shorter letter. -T.S. Eliot such a short, tiny ad: