In Liferay development,,<portlet:renderurl/> and <portlet:actionURL/> are the two portlet tags we often use.
We use common methods to illustrate the difference between them.
<portlet:renderURL/> usage Examples
First we will define a portlet:renderurl in the page, the variable name is Viewurl.
<portlet:renderurl var= "Viewurl" > <portlet:param name= "id" value= "123″/></portlet:actionurl>
The function of this code is to automatically generate a URL that contains the ID parameter:
Http://localhost:8080/group/demo/demo?p_p_id=demo_WAR_demoportlet&p_p_lifecycle=0&p_p_state=normal &p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_demo_war_demoportlet_id=123
The Renderurl is then referenced by means of a link, for example:
<a href= "<%=viewurl%>" > View </a>
Click the link, in the page or in the background Doview method, we can get the value of the parameter ID by the following methods:
Long id= paramutil.getlong (request, "id");
<portlet:actionURL/> Usage Examples
<portlet:actionurl var= "DeleteUrl" name= "delete" > <portlet:param name= "id" value= "123″/></portlet: Actionurl>
Unlike <portlet:renderURL/>, where there is more than one name property, the Name property value corresponds to the action method name delete of the Portlet daemon class.
The purpose of this code is to generate a URL that contains the parameter ID:
http://localhost:8080/group/demo/demo?p_auth=rjuz5r0r&p_p_id=demo_war_demoportlet&p_p_lifecycle=1& P_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_demo_war_demoportlet_id= 123&_demo_war_demoportlet_javax.portlet.action=delete
You can also refer to it in a linked way, for example:
<a href= "<%=deleteUrl%>" > Delete </a>
After clicking the link, in the Portlet class Delete method, we can also long id= paramutil.getlong (request, "id"), the method obtains the value of the parameter ID, and then deletes the data.
The difference between <portlet:renderURL/> and <portlet:actionURL/>
Together with the example, we can conclude that the difference between <portlet:renderURL/> and <portlet:actionURL/> has the following points:
1. <portlet:renderURL/> pass parameters are usually received in the background Doview method;<portlet:actionurl/> has the Name property to invoke the specified background method, and the parameter is also processed in the class
2. <portlet:renderURL/> is usually used to switch between pages, for example, view details;<portlet:actionurl/> processing operations that are typically used to delete, form submissions, and other business logic
The difference between "Liferay6.2" Renderurl and ActionURL