In portlet What is the best way to read namespace parameter in action method. My form contains
<input id="<portlet:namespace/>param1" name="<portlet:namespace/>param1" value='hello'/>
option1:
request.getParameter(response.getNamespace() + "param1");
option2:
request.getParameter("param1");
option1 does not work in liferay, but does seem will work in websphere. option2 works fine in liferay 6.2. option1 seems to work in before 6.1.
Can anyone please tell me what is the jsr 286 compliant way?
As I mentioned in a comment of an answer to this question, the problem is with Liferay 6.2 because IBM WebSphere and previous versions of Liferay are working as expected.
To solve this problem, I added the element
<requires-namespaced-parameters>false</requires-namespaced-parameters>
to theliferay-portlet.xml
of the/WEB-INF
directory of the portlet. By doing this, the parameters of the HTML forms are not "namespaced".Example of
/WEB-INF/liferay-portlet.xml
:If you add this element to the
liferay-portlet.xml
, the portlet still works correctly in previous versions of Liferay (I tested with versions 5.5 and 6.1). It also works with other portlet contains because they ignore this file.I claim that Liferay is behaving incorrectly because the JSR-286 spec says the following (top the page 76 of the spec):
There is no "jsr 286 compliant way" You can use both approach. The main purpose of usage tag is pass exact parameter to exact porlet when you have multiple portlet instances on same portal page. In this case same html inputs of different portlets have different names and every portlet will get his own page value.
Log statements at the end are from running the code in webphere
2014-02-12 19:35:23,877 DEBUG ..... renderPage==Namespace=>sites/Component Guide/Home.page 2014-02-12 19:35:23,877 DEBUG ..... renderPage==withoutnamespace=>null