开发者

Spring datagrid with checkboxes

I have a web-application in spring where tasks should be assigned to workers (say programmers).

  1. the application should be able to list tasks (unassigned tasks) in a grid
  2. On another side, the application should list workers (say programmers)
  3. the manager should be able to choose select tasks (or checking), and choose workers to whom he/she wishes to assign selected tasks
  4. hit submit button to assign selected tasks to chosen workers.

Now, form processing with spring is processed onSubmit(..., Command command, ...) by binding a command (in most of cases Model classes) to the form. How can I implement the functionality above, given 2 lists (one for workers and开发者_JAVA百科 another for tasks). I appreciate any idea, link to a resource or a link to the same question as mine.


Use the fact that values of checked checkboxes with similar names can be bound as array:

<form ...>
    Tasks:
    <c:forEach var = "task" items = "${tasks}">
        <input type = "checkbox" name = "taksIds" value = "${task.id}"> ${task.title}
    </c:forEach>

    Workers:
    <c:forEach var = "worker" items = "${workers}">
        <input type = "checkbox" name = "workerIds" value = "${worker.id}"> ${worker.name}
    </c:forEach>
</form>

-

class Command {
    private long[] taskIds;
    private long[] workerIds;

    ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜