File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Portals and Portlets and the fly likes Liferay MVC: Can a link call a portlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "Liferay MVC: Can a link call a portlet?" Watch "Liferay MVC: Can a link call a portlet?" New topic
Author

Liferay MVC: Can a link call a portlet?

Francis Zabala
Ranch Hand

Joined: Aug 11, 2010
Posts: 30
Hello guys,

May I ask if it is possible to have a link to call a portlet that hasn't been instantiated?

My case is like this, if the user clicks on the linke, the portlet where the user can view and edit his/her own profile shows up.

As of now, I have done this if the View/Edit portlet is added in the same page where another portlet that has the link is located. But if i remove the view/edit portlet (because I don't want the user to see the profiles before clicking the link), I get the error "You do not have the roles required to access this portlet."

Can anybody help me? Let me know if you need me to clear up my question above. Thanks!

Regards,
Francis
Jonas X. Yuan
author
Ranch Hand

Joined: May 18, 2008
Posts: 108
Hi Francis,

Hope that this chapter (Liferay Portal 6.1 Systems Development) could answer your questions.

Chapter 3, Generic MVC Portlets, first introduces how to develop a portlet project
with default templates. Then it addresses how to construct basic MVC portlets by
viewing the title and adding an action, and how to build advanced MVC portlets.
Finally, it discusses how to build and re-build services, how to bring portlets
into Control Panel, how to set security and permissions, dynamic query, and
custom SQL.

Thanks

Jonas Yuan

-----------
Blogs profile: http://www.liferay.com/web/jonas.yuan/profile
Author profile: http://www.packtpub.com/authors/profiles/jonas-x-yuan

Books: Liferay Portal 6.1 Systems Development
Abdelrahman Elghanam
Greenhorn

Joined: Feb 29, 2012
Posts: 4
PortletUrl can be used to create links to link you to any portlets on any of the portal pages, you can also specify the mode and phase to be the starting point of execution in the targeted portlet.
Amro Ali
Greenhorn

Joined: Feb 29, 2012
Posts: 25
the portlet for the profile is specific to the enterprise admin (control panel) you will need to edit the portlet.xml/liferay-portlet.xml to be available in pages outside.

place the portlet in a page on the website and set the link to visit that page with the portlet id and portlet state as maximized. for this specific case, the parameters would be something like this if your page is named myaccount

<url>/web/guest/my_account?p_p_id=2&p_p_lifecycle=0&p_p_state=maximized&p_p_col_id=column-1

this should get the logged in user details always. you don't need to worry about someone else viewing other people's information.
Tibi Kiss
Ranch Hand

Joined: Jun 11, 2009
Posts: 47
When you create a portlet url


you need the targetPageLayoutId (the plid). In case the url is created on the same page, the plid you can obtain easily from ThemeDisplay.
The problem appears, when you want cross page portlet url link.

A few days ago, I created such a portlet and I created a tiny portlet configuration screen where I can manually fill in the plid number, so that this special portlet will read the value from this manual configuration. But the plid I am finding by logging out the plid from within the portlet to whom I would like to link.
Ideal would be that I would have created the portlet configuration page which would search for pages containing the specified portletname, or just popping up a list of all page layouts (just like the menu structure in a dropdown list) then I would be able to find the plid of the selected page.

Somebody has such a concrete code snippet, which shows how to query the plid?
Amro Ali
Greenhorn

Joined: Feb 29, 2012
Posts: 25
Somebody has such a concrete code snippet, which shows how to query the plid?


please take a look at the getLayout methods in the com.liferay.portal.service.LayoutLocalServiceUtil this will return the layout and from it you can retrieve the plid
Tibi Kiss
Ranch Hand

Joined: Jun 11, 2009
Posts: 47
Amro Ali wrote:please take a look at the getLayout methods in the com.liferay.portal.service.LayoutLocalServiceUtil this will return the layout and from it you can retrieve the plid


Thank you, Ali.
Francis Zabala
Ranch Hand

Joined: Aug 11, 2010
Posts: 30
To all,

Thank you guys for all your replies. It turns out that I need to change my perpective when developing portlets. The solution I did was to create a new page and add the portlet that I need to use. So, I created a link from the main page that would go to the inner page where the portlet is currently deployed. Of course the link from the main page contains codes that would send data from the main page to the portlet page. I'll post the codes in case someone gets interested.

Regards,
Francis
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Liferay MVC: Can a link call a portlet?
 
Similar Threads
Portlet modes
mail upon registration
mail upon registration
Portlet Preferences not loading , portlet does not populate table values.
[Liferay] Protect portlet