Portlet Name Space Parameter in Liferay

Use Of Name Space Parameter in Liferay


Today we will discuss the use of Portlet Name Space parameter in Liferay.If you are using Liferay 6.1 then you can get the value of form input values easily but for Liferay 6.2 it is compulsory to use the namespaces.


Q) What is Portlet Name Space?
Ans:As you already know you can put many portlet on the same page in liferay.Let if there are 2 portlet on the same page and both have a input box with a same name like username what will happen answer is Name coflict. To avoid this name conflict we use portlet name space.

Portlet Name Space will give unique name to the elements in the page and these elements are associated to respective portlet. This will avoid name conflicts in the page.


How To Deal with Name Space?





Their are basically 3 ways:-

1)Use basic tags and provide entry in xml

 <form action="${namespace}" method="Post">
  Name :<input type="text" name="name" id="name"> 
<input type="Submit" name="Submit" value="Submit">
</form> 

and put requires-namespaced-parameters is false inside liferay-portlet.xml.

<requires-namespaced-parameters>
    false
</requires-namespaced-parameters>

2)Use <portlet:namespace/> tag with fields

<form action="${namespace}" method="Post">
Name :<input type="text" name="<portlet:namespace/>name" id="<portlet:namespace/>name">
<input type="Submit" name="Submit" value="Submit">
</form>

For using this you have to import taglib as:-

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

3)Use aui tags

<aui:form action="${namespace}" method="Post">
<aui:input name="name" id="name" />
<aui:button value="Submit" type="Submit"></aui:button>

</aui:form>

For using this you have to import taglib as:-

<%@taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>

Note:- Aui tags automatically append name spaces








Hope this will help....

 Related Post:-

Spring MVC portlet in Liferay

Form Handling in Spring Portlet

Many To Many Relationship mapping in Liferay Services

How to Use Ajax in Spring Portlet

Liferay Service Builder in Detail

How to install Maven

Creating Portlet/Services using Maven