Hi,
I'm developing a custom portlet for Liferay using Spring and Spring MVC. I have a form with select populated with values taken from a database.
The problem is that, when the form is displayed for the first time, it shows the values correctly. But when I click the submit button and redirect to the same view (parametrized in order to show form and results at a time), the form selects are empty.
I'm using the referenceData() method in SimpleFormController to populate the form selects. This is the relevant code of the form controller:
Note that I'm using the line response.setRenderParameter("action","advancedSear ch"). That is, when the user submits the form, this same controller takes control again.Code:public class AdvancedSearchController extends SimpleFormController{ private SearchService searchService; public AdvancedSearchController(){ setCommandName("advancedSearch"); setCommandClass(AdvancedSearchCriteria.class); setFormView("beginAdvancedSearch"); } public void setSearchService(SearchService searchService) { this.searchService = searchService; } protected Map referenceData(PortletRequest request,Object command,Errors errors) throws Exception{ Map<String, Object> refdata = new HashMap<String, Object>(); refdata.put("tipos", getTipos()); refdata.put("modalidades", getModalidades()); refdata.put("planes", getPlanesFormacion()); return refdata; } protected void onSubmitAction (ActionRequest request, ActionResponse response, Object command, BindException errors) throws Exception { AdvancedSearchCriteria search = (AdvancedSearchCriteria)command; response.setRenderParameter("action", "advancedSearch"); List<TbAccionesFormativa> courses = searchService.listTbAccionesFormativaAdvanced(search); request.setAttribute("courses", courses); response.setRenderParameter("p_p_state", WindowState.MAXIMIZED.toString()); }
Anybody has any suggestion? If there is a better way to get the functionality that I want, I'd like to read your suggestions.
Thanks in advance.
Mario.


Reply With Quote
.