Fórum
Add Portelt programatically on Layout
Jay Trivedi, modificado 11 Anos atrás.
Add Portelt programatically on Layout
Regular Member Postagens: 109 Data de Entrada: 24/11/12 Postagens Recentes
Hey Friends,
I want to programatically add Portlet on Layout.
I tried this
I followed http://www.liferay.com/community/wiki/-/wiki/Main/Programmatically+Create+a+Layout+and+Place+a+Portlet+on+it
But i don't get any output neither i find any updates in ProtletPrefernces and Layout Table.
Let me share some details.
- > I have created Group Programatically.
-> Later i realized that i need to create layout for it.
-> Now the acutal requirement starts i need to add document and library portlet for that particular group to share documents for that group.
-> So i decided to dynamically create a page and set layout for it.[did it successfully]
-> Now i want to add Document and media portlet for that gorup.
-> But i am failing to do it.
Any Suggestions.
I want to programatically add Portlet on Layout.
I tried this
/ add a content display portlet
// The column id and position (last 2 parameters below) will depend on your layout template
String journalPortletId = layoutTypePortlet.addPortletId(userId,
PortletKeys.JOURNAL_CONTENT,
"column-3",
-1);
long companyId = themeDisplay.getCompanyId();
long ownerId = PortletKeys.PREFS_OWNER_ID_DEFAULT;
int ownerType = PortletKeys.PREFS_OWNER_TYPE_LAYOUT;
// Retrieve the portlet preferences for the journal portlet instance just created
PortletPreferences prefs = PortletPreferencesLocalServiceUtil.getPreferences(companyId,
ownerId,
ownerType,
layout.getPlid(),
journalPortletId);
// set desired article id for content display portlet
prefs.setValue("article-id", "123456");
prefs.setValue("group-id", String.valueOf(groupId));
// update the portlet preferences
PortletPreferencesLocalServiceUtil.updatePreferences(ownerId, ownerType, layout
.getPlid(), journalPortletId, prefs);
I followed http://www.liferay.com/community/wiki/-/wiki/Main/Programmatically+Create+a+Layout+and+Place+a+Portlet+on+it
But i don't get any output neither i find any updates in ProtletPrefernces and Layout Table.
Let me share some details.
- > I have created Group Programatically.
-> Later i realized that i need to create layout for it.
-> Now the acutal requirement starts i need to add document and library portlet for that particular group to share documents for that group.
-> So i decided to dynamically create a page and set layout for it.[did it successfully]
-> Now i want to add Document and media portlet for that gorup.
-> But i am failing to do it.
Any Suggestions.
Apoorva Prakash, modificado 11 Anos atrás.
RE: Add Portelt programatically on Layout
Liferay Master Postagens: 658 Data de Entrada: 15/06/10 Postagens RecentesJay Trivedi:
Hey Friends,
I want to programatically add Portlet on Layout.
I tried this/ add a content display portlet // The column id and position (last 2 parameters below) will depend on your layout template String journalPortletId = layoutTypePortlet.addPortletId(userId, PortletKeys.JOURNAL_CONTENT, "column-3", -1); long companyId = themeDisplay.getCompanyId(); long ownerId = PortletKeys.PREFS_OWNER_ID_DEFAULT; int ownerType = PortletKeys.PREFS_OWNER_TYPE_LAYOUT; // Retrieve the portlet preferences for the journal portlet instance just created PortletPreferences prefs = PortletPreferencesLocalServiceUtil.getPreferences(companyId, ownerId, ownerType, layout.getPlid(), journalPortletId); // set desired article id for content display portlet prefs.setValue("article-id", "123456"); prefs.setValue("group-id", String.valueOf(groupId)); // update the portlet preferences PortletPreferencesLocalServiceUtil.updatePreferences(ownerId, ownerType, layout .getPlid(), journalPortletId, prefs);
I followed http://www.liferay.com/community/wiki/-/wiki/Main/Programmatically+Create+a+Layout+and+Place+a+Portlet+on+it
But i don't get any output neither i find any updates in ProtletPrefernces and Layout Table.
Let me share some details.
- > I have created Group Programatically.
-> Later i realized that i need to create layout for it.
-> Now the acutal requirement starts i need to add document and library portlet for that particular group to share documents for that group.
-> So i decided to dynamically create a page and set layout for it.[did it successfully]
-> Now i want to add Document and media portlet for that gorup.
-> But i am failing to do it.
Any Suggestions.
Hello Jay,
Have a look on this blog, you may find it useful.
Hope this will help...
Thanks and Regards,
Apoorva Prakash
Luca Angelini, modificado 10 Anos atrás.
RE: Add Portelt programatically on Layout
New Member Postagens: 2 Data de Entrada: 15/05/13 Postagens Recentes
Hi,
I also follow the wiki to add JOURNAL_CONTENT to a new layout programmatically.
Everything seems to be correct, but when I open the page the portlet doesn't display any article.
I've tried this 2 solutions but nothing.
If I debug html/portlet/journal_content/view.jsp the param "articleId" is always null. Any solution?
I also follow the wiki to add JOURNAL_CONTENT to a new layout programmatically.
Everything seems to be correct, but when I open the page the portlet doesn't display any article.
I've tried this 2 solutions but nothing.
PortletPreferences prefs = PortletPreferencesLocalServiceUtil.getPreferences(companyId, ownerId, ownerType, newPage.getPlid(), journalPortletId);
prefs.setValue("articleId", content.getArticleId());
prefs.setValue("groupId", String.valueOf(groupId));
//prefs.setValue("article-id", content.getArticleId());
//prefs.setValue("group-id", String.valueOf(groupId));
If I debug html/portlet/journal_content/view.jsp the param "articleId" is always null. Any solution?
vasv kumar, modificado 10 Anos atrás.
RE: Add Portelt programatically on Layout
Junior Member Postagens: 46 Data de Entrada: 07/02/11 Postagens Recentes
Hi,
prefs.setValue("articleId", content.getArticleId());
prefs.setValue("groupId", String.valueOf(groupId));
The above statements are working.Just now i checked
Thanks
Vissu
prefs.setValue("articleId", content.getArticleId());
prefs.setValue("groupId", String.valueOf(groupId));
The above statements are working.Just now i checked
Thanks
Vissu