0
votes

I want to make portlet with filter and search results. filter have to be send in get method. I`m using spring annotation @ModelAttribute for filter. But all properties in filter are null, because liferay use prefix for url parameters like _[PORTLET_NAME]_WAR_[WAR_NAME]. I used actionRequest and sended filter by post method and it workek, but i need parameters in url.

Method in controller:

@RequestMapping
public String view(@ModelAttribute("filter") ProcessSearchFilter filter, RenderRequest request, Model model)

when parameter name is _processSearch_WAR_portlets_text=test, in filter property text is test, but i want use just text parameter in url.

any idea how it make?

2

2 Answers

1
votes

From Liferay 6.2 it is necessary to declare name-space prefixes for the fields on your view page. If you are not recieving any values from the submitted form, then try either setting the prefixes like this

<input type="text" name="<portlet:namespace />inputTextName" />

or changing the settings of your portlet so it doesn't require them. In liferay-portlet.xml set the requires-namespaced-parameters tag to false for the selected portlet.

0
votes

If you have "text" parameter in url then you can use, instead if @ModelAttribute

@RequestParam("text") String text

or, if param variable name is same as parameter name

@RequestParam String text

Also note that @RequestParam, as shown above, makes parameter required by default. If this is not wanted use

@RequestParam(value = "text", required = false) String text

Your render method should (also) have @RenderMapping annotation.