Skip to content
Snippets Groups Projects
Commit 2218110b authored by Bruno Nocera Zanette's avatar Bruno Nocera Zanette
Browse files

Update solution for Estado/Munic list's request

Updated the solution for "Estado/Munic" list's request to use base URL
instead of the current URL. This avoids the system to crash when the URL
is a bit different, for instance when another field has been modified.
parent abdb9228
Branches
No related tags found
No related merge requests found
...@@ -373,13 +373,13 @@ public class OcorrenciaMunicipalController { ...@@ -373,13 +373,13 @@ public class OcorrenciaMunicipalController {
return "redirect:/ocorrenciamunicipais/"+str; return "redirect:/ocorrenciamunicipais/"+str;
} }
@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "text/html") @RequestMapping(params = "uf", method = RequestMethod.GET, produces = "text/html")
public String get(@PathVariable(value = "id") String uf, @Valid OcorrenciaMunicipal ocorrenciaMunicipal, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) { public String getMunicipios(@RequestParam(value = "uf", required = false) String uf, Model uiModel) {
repopulateMunicipios(uf, uiModel, ocorrenciaMunicipal); repopulateMunicipios(uf, uiModel);
return "ocorrenciamunicipais/selectmunicipios"; return "ocorrenciamunicipais/selectmunicipios";
} }
void repopulateMunicipios(String uf, Model uiModel, OcorrenciaMunicipal ocorrenciaMunicipal) { void repopulateMunicipios(String uf, Model uiModel) {
List<Municipio> lm = Municipio.findAllMunicipiosByUf(uf); List<Municipio> lm = Municipio.findAllMunicipiosByUf(uf);
uiModel.addAttribute("municipios", lm); uiModel.addAttribute("municipios", lm);
} }
......
...@@ -36,10 +36,15 @@ ...@@ -36,10 +36,15 @@
//ID of the chosen "estado" //ID of the chosen "estado"
uf=document.getElementsByName("uf")[0].value; uf=document.getElementsByName("uf")[0].value;
//Get complete base URL
if (!window.location.origin)
window.location.origin = window.location.protocol+"//"+window.location.host;
RequestBaseUrl = window.location.origin + "/participatorio" + "/ocorrenciamunicipais";
//Create and send to server a request of //Create and send to server a request of
//the list of "Municipios" that belongs to the "Estado" chosen //the list of "Municipios" that belongs to the "Estado" chosen
xmlhttp = new XMLHttpRequest(); xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "ocorrenciamunicipais/"+uf ,false); xmlhttp.open("GET", RequestBaseUrl + "?uf=" + uf ,false);
xmlhttp.send(); xmlhttp.send();
//Create a temporary html document to store the html code //Create a temporary html document to store the html code
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment