Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok so apparently I had to make a propertyEditor for Developer. There is a good explanation on this site:</p> <p><a href="http://static.springsource.org/spring/docs/2.0.x/reference/validation.html" rel="nofollow">http://static.springsource.org/spring/docs/2.0.x/reference/validation.html</a></p> <p>Edit extra information:</p> <p>So apparently when you check a checkbox it will give you the value as a string. Ofcourse the Collection had to be made with developer objects. </p> <p>So I created a developerEditor:</p> <pre><code>package domainmodel; import java.beans.PropertyEditorSupport; public class DeveloperEditor extends PropertyEditorSupport { private GameOrganizer gameOrganizer; public void setGameOrganizer(GameOrganizer gameOrganizer) { this.gameOrganizer = gameOrganizer; } @Override public void setAsText(String id) { long id2 = Long.parseLong(id); Developer type = gameOrganizer.getDeveloper(id2); setValue(type); } } </code></pre> <p>And with the checkboxes I gave as itemvalue the id of the object</p> <pre><code>&lt;form:checkboxes id="selectdeveloper" items="${allDevelopers}" itemValue="id" path="developers" itemLabel="name" /&gt; </code></pre> <p>Then in the formcontroller I override the initBinder method. So that when I Spring has to fill in a developer object it will first convert it from string to a Developer Object using my editor.</p> <pre><code> private DeveloperEditor developerEditor; public void setDeveloperEditor(DeveloperEditor developerEditor){ this.developerEditor = developerEditor; developerEditor.setGameOrganizer(gameOrganizer); } @Override protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) { binder.registerCustomEditor(Developer.class, developerEditor); } </code></pre> <p>That's it folks. If anyone has any questions I will be glad to answer them.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload