2
Basically I have the code below:
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>
<link rel="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>
<div class="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 executing the code, I pass values(Object) from one checkbox to another and vice versa, I would like that when you click to record I pass the objects of these checkboxes as a List, to be treated in the Controller.
I tried to do the following way, that ends up returning me a List but only comes an object.
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 you go to this Controller method:
@Get("/permissao/perfis/{id}/{perfisUtilizados},{perfisDisponiveis}")
public void salvarPerfisDaPermissao(Long id, List<Perfil> perfisUtilizados,
List<Perfil> perfisDisponiveis){
//Implementação
}
How to solve?
What is the default expected by the server? Comma-separated words? Wouldn’t it be better to send this data in the body of the request?
– user21448
@Nevershowmyface the expected by the server would be 2 Lists of type Profile, this is the object passed in value, above is just an example so that it can be exemplified and can show the functioning, as it would send the data in the body of the request?
– Tiago Ferezin