diff --git a/src/main/java/br/ufpr/c3sl/estacaojuventude/web/OcorrenciaMunicipalController.java b/src/main/java/br/ufpr/c3sl/estacaojuventude/web/OcorrenciaMunicipalController.java index 4ed1b7f0ee99f3e1751a43b73533fc9b3c8fa753..4bcdf7d1ae686b87b3d6edc65f2a2b97c732209d 100644 --- a/src/main/java/br/ufpr/c3sl/estacaojuventude/web/OcorrenciaMunicipalController.java +++ b/src/main/java/br/ufpr/c3sl/estacaojuventude/web/OcorrenciaMunicipalController.java @@ -373,13 +373,13 @@ public class OcorrenciaMunicipalController { return "redirect:/ocorrenciamunicipais/"+str; } - @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "text/html") - public String get(@PathVariable(value = "id") String uf, @Valid OcorrenciaMunicipal ocorrenciaMunicipal, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) { - repopulateMunicipios(uf, uiModel, ocorrenciaMunicipal); + @RequestMapping(params = "uf", method = RequestMethod.GET, produces = "text/html") + public String getMunicipios(@RequestParam(value = "uf", required = false) String uf, Model uiModel) { + repopulateMunicipios(uf, uiModel); return "ocorrenciamunicipais/selectmunicipios"; } - void repopulateMunicipios(String uf, Model uiModel, OcorrenciaMunicipal ocorrenciaMunicipal) { + void repopulateMunicipios(String uf, Model uiModel) { List<Municipio> lm = Municipio.findAllMunicipiosByUf(uf); uiModel.addAttribute("municipios", lm); } diff --git a/src/main/webapp/WEB-INF/views/ocorrenciamunicipais/create.jspx b/src/main/webapp/WEB-INF/views/ocorrenciamunicipais/create.jspx index ae7be54196d6e3079354e096a8da93cc83c04edc..e6e27940280d0b28eedb56c075676be9047777bf 100644 --- a/src/main/webapp/WEB-INF/views/ocorrenciamunicipais/create.jspx +++ b/src/main/webapp/WEB-INF/views/ocorrenciamunicipais/create.jspx @@ -35,11 +35,16 @@ //ID of the chosen "estado" 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 //the list of "Municipios" that belongs to the "Estado" chosen xmlhttp = new XMLHttpRequest(); - xmlhttp.open("GET", "ocorrenciamunicipais/"+uf ,false); + xmlhttp.open("GET", RequestBaseUrl + "?uf=" + uf ,false); xmlhttp.send(); //Create a temporary html document to store the html code