Hi!
I've a command form object that contains some informations and that include a list of countries that I wanna render as a combobox.
My SimpleFormController have a "service" with a getData method that returns a list of Countries and I wanna load this country list in my model (the command object)
I've tryed to do it this way:
but the object rendered by the view this way:Code:@Override public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { FormRegistrazioneCommand command = (FormRegistrazioneCommand) getCommand(request); command.setListaPaesi(countryService.getData()); command.setPaeseSelezionato((Country)countryService.getDefault()); return new ModelAndView(getFormView(),getCommandName(),command); }
where FormRegistrazioneCommand is defined asCode:<form:form method="POST" name="myForm" commandName="formRegistrazioneCommand" action="riepilogo"> <form:input path="persona.nome"></form:input> <form:input path="persona.cognome"></form:input> <form:select path="paeseSelezionato.codicePaese"> <form:option value="0" label="Select" /> <form:options items="${listaPaesi}" itemValue="codicePaese" itemLabel="nomePaese" /> </form:select> <input type="submit"/> </form:form>
have no "options" inside the combo.Code:public class FormRegistrazioneCommand { private Persona persona; private List<Country> listaPaesi; private Country paeseSelezionato; //OMISSIS - GETTERS AND SETTERS }
I've tryed also to override formBackingObject
with no results.Code:@Override protected Object formBackingObject(HttpServletRequest request) throws Exception { FormRegistrazioneCommand command = (FormRegistrazioneCommand) super.formBackingObject(request); command.setListaPaesi(countryService.getData()); command.setPaeseSelezionato((Country)countryService.getDefault()); return command; }
What I can't figured out is the lifecycle of the command object behind the form. When is it created? How can I hook into the creation process and how can I load additional as I want?
I read something about referenceData method but I don't like it so much, I prefere have only one object behind a form contains all model objects needed.
P.S. I know SimpleFormController is deprecated but at this time I am trying to get my hands dirty with a full xml-oriented and 2.5 spring style small example before start a newer (and better) Spring 3, annotation oriented case of study.
Thanks!


Reply With Quote
