Springboot, powiązanie checkboxa z atrybutem obiektu

0

Cześć,
mam w templatce listę obiektów dla których w każdym rzędzie wypisuję ich atrybuty. ostatnim atrybutem jest checkbox. jeśli jest on zaznaczony, to Submit powinien przekazywać do następnej templatki tylko wybrane obiekty. taka jest idea..;P
Niestety sprawdzanie w konsoli pokazuje, że lista "wybrańców" jest pusta. proszę o wsparcie:

część templatki:

    <form action="/firstsquadchoice" method="post">
        <table class="table">
            <thead>
            <tr>
                <td>PLAYER'S NAME</td>
                <td>POSITION</td>
                <td>FIRST SQUAD</td>
            </tr>
            </thead>
            <tbody th:each="player : ${players}">
            <tr>
                <td th:text="${player.firstName}"></td>
                <td>
                    <div class="col-md-5 ">
                        <form method="post" th:object="${players}">
                            <div class="form-group">
                                <select class="form-control selectpicker" th:value="${player.position}"
                                        id="playerPosition" name="playerPosition" required autofocus>              
                                    <option value="">Not selected</option>
                                    <option th:each="player : ${T(pl.com.k1313.goal4goal.domain.Position).values()}"
                                            th:value="${player}"
                                            th:text="${player}">player

                                    </option>
                                </select>
                            </div>
                        </form>
                    </div>
                </td>
                <td>
                    <input type="checkbox" th:value="${player.firstSquadPlayer}" id="firstSquadPlayer"
                           name="firstSquadPlayer" >
                </td>
                <td><a th:href="${'/player?id='+player.id}">Details</a></td>
                <td><a th:href="${'/player/delete/'+player.id}">Fire Player</a></td>
            </tr>
            </tbody>
        </table>

        <button class="btn btn-primary" type="submit">CONFIRM FIRST 11</button>
    </form>


controller:

    @RequestMapping(value = "/firstsquadchoice", method = RequestMethod.POST)
    public String getFirstSquad(Model model) throws ExecutionControl.NotImplementedException {
        List<Player> firstSquadPlayers = playerService.getFirstSquad();
        List<Player> players = playerService.getAllPlayers();
        model.addAttribute("players", players);
        model.addAttribute("firstsquadplayers", firstSquadPlayers);
        model.addAttribute("timeComponent", timeComponent);
        model.addAttribute("userInformation", userInformation);
        return "firstsquad";
    }

obsługa:

  @Override
    public Collection<Player> getFirstSquad() throws ExecutionControl.NotImplementedException {
        List<Player> firstSquad = players.values().stream().filter(player -> player
                .isFirstSquadPlayer())
                .collect(Collectors.toList());
        System.out.println("Zawodnicy z 11: " + firstSquad);
        return firstSquad;

    }

Templatka "firstsquad" jest wyświetlana, błędów nie wyrzuca, ale jak wspomniałem lista "wybrańców" jest pusta.....

1

@k1313: no dobra, skoro chcesz sobie robić krzywdę. Pytasz o ten:

<input type="checkbox" th:value="${player.firstSquadPlayer}" id="firstSquadPlayer"
                           name="firstSquadPlayer" >

Checkbox? Jest poza <form> więc siłą rzeczy nie jest nigdzie przekazywany kiedy submitujesz formularz.

1 użytkowników online, w tym zalogowanych: 0, gości: 1