Portray Navigation in Liferay

Thus, I am having trouble figuring out how to handle navigation in liferay. I am new to jsp, portlets and liferay, but I think I have exhausted all the documentation that is looking for an answer.

I am looking for a way to submit an html form and set rendering options with fields. I would like to have URLs that work with normal browser navigation and bookmarks. I figured out how to do this using javascript to update an already declared renderurl with new values ​​from the form, but I'm trying to find a cleaner way to do this.

I tried several methods right now .. 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 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 changed the form to get, then I get this url:

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

But using renderURL with a set of parameters, I would get this, which is a combination of how both messages are returned and get:

 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 now I can use the form with the message, and ParamUtil.getString will recognize the data, but the link will not be classified, or I can use the form with get, leaving the information in the URL, but I can not get ParamUtil to recognize the data. Even if I could get the recognition data using the receive form, I really do not want to use this, since the parameter will not be saved if I do any form submissions in other portlets. As far as I understand, RenderURLs save these things.

Forgive me if I completely get rid of these things, please. I am new to jsp, portlets and liferay and am pretty lost on how I should do a lot of such things.

+4
source share
2 answers

since you need to use

 <portlet:actionURL> 

submit an action to process the form .....

+1
source

What you must first understand (and which took me a lot of time) is the portlet workflow.

The portlet either does the process of its action.

When the action of the portlet is called, it will also be automatically asked to execute its visualization method (after its action).

Like facts

  • If you want to just display the portlet
    • renderUrl
  • If you want to send information to the portlet
    • actionUrl
  • if you change the configuration or settings of the portlet
    • configurationUrl

This is purely theoretical, as you can ruin this entire workflow. However, I would not recommend that you do this for several reasons, for example:

  • he interrupts maintainability
  • you will not be able to use some of the built-in logic and your own workflows that are really powerful
  • you take great responsibility for making it work.

Now, if you want to get the values ​​of the form fields in the process action, they will be available as query parameters.

If you want to get portlet settings, I recommend that you read some portlet configuration information in the liferay wiki .

It also seems to you that you want to send action requests or visualization requests from a portlet to another.
Always keep in mind that liferay-portlet: the actionURL tag and liferay-portlet: the renderURL tag has a portletName attribute that allows you to specify a portlet other than the current one.

Hope this helps. Feel free to ask if I am not clear enough or if other questions arise.

+1
source

Source: https://habr.com/ru/post/1387609/


All Articles