Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Ravi Kiran
Why to use PortletURL?
April 16, 2012 1:18 PM
Answer

Ravi Kiran

Rank: Junior Member

Posts: 53

Join Date: April 7, 2012

Recent Posts

This thread is not a question , it was a doubt raised when i was going through LLiferay Forums about using
PortletURL


In Somecase i see this PortletURL inside the javscript Method


<script>
function createRowURL() {
var portletURL = new Liferay.PortletURL();
portletURL.setParameter("rowNumber", "25" );
return portletURL.toString();
}

</script>



In Somecase i see this PortletURL inside the doView Method as shown


To get currentURL :

PortletURL url = PortletURLUtil.getCurrent(renderRequest, mimeResponse or renderResponse)

creating PortletURL from renderResponse :

a.For RenderURL:
PortletURL renderURL = renderResponse.createRenderURL();
b.For actionURL:
PortletURL actionURL = renderResponse.createActionURL();


Could anybody please tell me in which case PortletURL would be useful ??

Thanks in advance

Once again i am sorry if this wasted your time .
David H Nebinger
RE: Why to use PortletURL?
April 16, 2012 1:50 PM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11102

Join Date: September 1, 2006

Recent Posts

Dude, you really need to read a book or something...

Action URLs are used to invoke an action on the portlet, i.e. as a result of clicking on a button. It allows the portlet the chance to change it's current context (i.e. save to a database, validate parameters, or whatever).

Render URLs are used to invoke the rendering of a portlet, and should never involve some sort of state change. Renders occur when the portal wants the portlet to re-render it's content (i.e. some other portlet was invoked using an action url, now all of the portlets need to re-render their content so the portal can generate the aggregated page).

The javascript example is used to create a URL that the JS can call to invoke an action in the portlet, one that is not specified by the dom elements already on the page (which would have appropriate action urls already tied to them).
Hitoshi Ozawa
RE: Why to use PortletURL?
April 16, 2012 2:55 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Portlet is only a fragment of a web page and there may be several portlets in a web page. As such, URI which you enter is your web browser to display a web page is not sufficient to determine the uri of a portlet. portlet url contains information to specify which portlet to display a page and which portlet the post was from. Otherwise, the entire portlets on a page will be refreshed and posted to instead of just one.