Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Portlet Navigation in Liferay

So I'm having some trouble figuring out how to handle navigation in liferay. I'm new to jsp, portlets, and liferay, but I think I've exhausted all of the documentation looking for an answer.

I'm looking for a way to submit an html form and set render parameters with the fields. I would like to have URLs that work with normal browser navigation, and bookmarkable urls. I have figured out a way to do it by using javascript to update an already declared renderurl with new values from the form, but I'm trying to figure out a cleaner way of doing so.

Right now I've tried a few methods.. using this page

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<%@ page import="com.liferay.portal.kernel.util.ParamUtil" %>
<%@ page import="com.liferay.portal.kernel.util.Validator" %>
<%@ page import="javax.portlet.PortletPreferences" %>

<portlet:defineObjects />


<%
    PortletPreferences prefs = renderRequest.getPreferences();
    String search = ParamUtil.getString(renderRequest, "search");
%>

<portlet:renderURL var="viewURL">
<portlet:param name="jspPage" value="/view.jsp" />
</portlet:renderURL>

<aui:form action="<%= viewURL %>" method="post">
     <aui:input label="search" name="search" type="text" value="<%=search %>" />
     <aui:button type="submit" />
</aui:form>

Using post, I'd get the resulting url:

http://localhost:8080/web/10157/home?p_p_id=search_WAR_searchportlet_INSTANCE_Kt9C&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_search_WAR_searchportlet_INSTANCE_Kt9C_jspPage=%2Fview.jsp

If I change the form to get, then I get this url:

http://localhost:8080/web/10157/home?_search_WAR_searchportlet_INSTANCE_Kt9C_search=123

But using a renderURL with the parameter set, I'd get this, which is a combination of what both post and get would return:

http://localhost:8080/web/10157/home?p_p_id=search_WAR_searchportlet_INSTANCE_Kt9C&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_search_WAR_searchportlet_INSTANCE_Kt9C_jspPage=%2Fview.jsp&_search_WAR_searchportlet_INSTANCE_Kt9C_search=123

So for now, I can either use a form with post, and ParamUtil.getString will recognize the data, but the link will not be bookmarkable, or I could use a form with get, leaving information in the url, but I cannot get ParamUtil to recognize the data. Even if I could get the data to be recognized using a get form, I really don't want to use that, as the parameter will not be preserved if I'm doing any submitting from forms in other portlets. From what I understand, RenderURLs preserve these things.

Pardon me if I'm completely off on these things, please. I am new to jsp, portlets, and liferay and rather lost on how I'm supposed to do a lot of these things.

like image 512
TICKETS Avatar asked Nov 04 '22 09:11

TICKETS


1 Answers

as u need to use

<portlet:actionURL>

for handling form submit action.....

like image 131
Laxman Rana Avatar answered Nov 27 '22 19:11

Laxman Rana