Basically I have the following code:
var associar = $("#associar");
var desassociar = $("#desassociar");
var permissoes = $("#permissoes");
var minhasPermissoes = $("#minhasPermissoes");
var gravar = $("#gravar");
associar.click(function() {
minhasPermissoes.append(permissoes.find('option:selected'));
});
desassociar.click(function() {
permissoes.append(minhasPermissoes.find('option:selected'));
});
gravar.click(function(){
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script><linkrel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script><divclass="container">
<div class="row">
<div class="col-md-6">
<label>Permissões</label>
<select id="permissoes" class="form-control" multiple>
<option value="Clientes">Clientes</option>
<option value="Boletos">Boletos</option>
<option value="Usuarios">Usuários</option>
<option value="Configuracoes">Configurações</option>
</select>
</div>
<div class="col-md-6">
<label>Minhas Permissões</label>
<select id="minhasPermissoes" class="form-control" multiple>
</select>
</div>
</div>
<br>
<button id="associar" class="btn btn-primary">Associar</button>
<button id="desassociar" class="btn btn-primary">Desassociar</button>
<button id="gravar" class="btn btn-primary" style="float:right;">Gravar</button>
<div id="texto">
</div>
As you can see by running the code, I pass values (Object) from one checkbox to another and vice versa, I would like that when I click on record I pass the objects from these checkboxes as a List, to be treated on the Controller.
I tried doing the following, which ends up returning a List but only one object comes in.
var perfisUtilizados = [];
perfisUtilizados = $('#selectPerfisUtilizados').find('option');
var perfisDisponiveis = [];
perfisDisponiveis = $('#selectPerfisDisponiveis').find('option');
gravar..click(function() {
location.href = '${pageContext.request.contextPath}/permissao/perfis/${id}/' + perfisUtilizados + "," + perfisDisponiveis;
});
And when you click on the record it passes to this method of Controller:
@Get("/permissao/perfis/{id}/{perfisUtilizados},{perfisDisponiveis}")
public void salvarPerfisDaPermissao(Long id, List<Perfil> perfisUtilizados,
List<Perfil> perfisDisponiveis){
//Implementação
}
How to solve?