Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7911927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:26:02+00:00 2026-06-03T13:26:02+00:00

I have a game and a developer. The game has a set of developers.

  • 0

I have a game and a developer. The game has a set of developers. I want to create a form where I can add a game to the database. In the form I enter the name, price and check the developers. So i create a checkbox for every developer. However when I check those the page just seems to refresh. When I debug it seems that my controller never gets to the doSubmitAction function. When I leave out the checkboxes everything works as it is supposed to.
Is spring unable to create the collection? I don’t understand fully what is happening behind the scenes of Spring. This is my first project I’m creating using spring.

Here is my form:

 <form:form method="POST" commandName="game" >
                    <table>
                        <tr>
                            <td>
                                Name
                            </td>
                            <td>
                                <form:input path="gameNaam" size="20" />
                            </td>
                        </tr>

                        <tr>
                            <td>Choose Developers</td>
                            <td>
                                <form:checkboxes id="selectdeveloper" items="${developers}" path="developers" itemLabel="naam" />

                            </td>
                        </tr>
                        <tr>
                            <td>
                               Price
                            </td>
                            <td>
                                <form:input path="prijs" size="10" />
                            </td>
                        </tr>
                        <tr>
                            <td>

                                <input type="submit" value="Add" />

                            </td>
                            <td></td>
                        </tr>

                    </table>
                </form:form>

And the formController:

public class GameFormController extends SimpleFormController {

    private GameOrganizer gameOrganizer;

    public GameFormController() {
       setCommandClass(Game.class);
       setCommandName("game");
       setFormView("AddGame");
       setSuccessView("forward:/Gamedatabase.htm");
   }

    public void setGameOrganizer(GameOrganizer gameOrganizer){
       this.gameOrganizer=gameOrganizer;
    }

    @Override
    protected Object formBackingObject(HttpServletRequest request) throws Exception {
       Game game = null;
       long id = ServletRequestUtils.getLongParameter(request, "id");
       if(id<=0){
           game = new Game();
       }else{
           game = gameOrganizer.getGame(id);
       }
       return game;
    }



    @Override
    protected void doSubmitAction(Object command) throws Exception {

        Game game = (Game) command;
        if(game.getId()<=0){
            gameOrganizer.addGame(game);
        }else{
           gameOrganizer.update(game);

       }

   }

   @Override
   protected Map referenceData(HttpServletRequest request) throws Exception {
       Set<Developer> developers = gameOrganizer.getAllDevelopers();
       HashMap<String, Object> map = new HashMap<String, Object>();
      map.put("developers", developers);
      return map;
   }


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:26:04+00:00Added an answer on June 3, 2026 at 1:26 pm

    Ok so apparently I had to make a propertyEditor for Developer.
    There is a good explanation on this site:

    http://static.springsource.org/spring/docs/2.0.x/reference/validation.html

    Edit extra information:

    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.

    So I created a developerEditor:

    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);
        }
    }
    

    And with the checkboxes I gave as itemvalue the id of the object

    <form:checkboxes id="selectdeveloper" items="${allDevelopers}" itemValue="id" path="developers" itemLabel="name" />
    

    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.

     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);
    }
    

    That’s it folks.
    If anyone has any questions I will be glad to answer them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a casual game that has become a modest hit on a
I have developed tower of hanoi game in java script. Now, I want to
I want to develop a 2d game. I have to choose from Quartz/CoreGraphics, OpenGL
I'm developing a game. I want to have game entities each have their own
I'm a developer of a game in c#, and I have a security feature
Good day everyone, I'm an independent game developer who has, in the past, primarily
I have developed an AJAX based game where there is a bug caused (very
I am currently developing an rpg type game in C++. I have developed a
I develop a game that will have to load jpg images that now i
I have a simple game that I am building in as3/air using flash develop,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.