What about using the interface Controller instead of the class SimpleFormController?
I did this way:
Code:
public class UnidadeController implements Controller {
private final Log log = LogFactory.getLog(UnidadeController.class);
private UnidadeManager mgr = null;
public void setUnidadeManager(UnidadeManager unidadeManager) {
this.mgr = unidadeManager;
}
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'handleRequest' method...");
}
String cdClassificacaoInstitucional = null;
String cdEntidade = null;
String dcEntidade = null;
Map model = new HashMap();
cdClassificacaoInstitucional = request.getParameter("cdClassificacaoInstitucional");
cdEntidade = request.getParameter("cdEntidade");
dcEntidade = request.getParameter("dcEntidade");
//Primeira vez que este formulario for requisitado, a consulta será efetuada com valores default
if (cdClassificacaoInstitucional == null){
[u]model.put("entidades"[/u], mgr.getEntidadesPorCdClassificacao(new Integer(2)));
[u] model.put(Constants.UNIDADE_LIST[/u], mgr.getEntidadesPorCdClassificacao(new Integer(2)));
}else if (cdEntidade == null){
model.put("entidades", mgr.getEntidadesPorCdClassificacao(Integer.valueOf(cdClassificacaoInstitucional)));
model.put(Constants.UNIDADE_LIST, mgr.getEntidadesPorCdClassificacao(Integer.valueOf(cdClassificacaoInstitucional)));
}else if(cdEntidade == null || dcEntidade.length() == 0) {
model.put("entidades", mgr.getEntidadesPorCdEntidadeMembroDE(Integer.valueOf(cdEntidade)));
model.put(Constants.UNIDADE_LIST, mgr.getEntidadesPorCdEntidadeMembroDE(Integer.valueOf(cdEntidade)));
}else if (log.isDebugEnabled()) {
log.debug("Requisicoes subsequentes, neste caso o usuario OPTOU PELA CONSULTA PERSONALIZADA"+dcEntidade);
}
model.put("entidades", mgr.getEntidadesPorDcEntidade(Integer.valueOf(cdEntidade),dcEntidade));
model.put(Constants.UNIDADE_LIST, mgr.getEntidadesPorDcEntidade(Integer.valueOf(cdEntidade),dcEntidade));
}
}
}
return new ModelAndView("unidadeList",model );
}
}
I hope this help!
Gilbeto