Foren

Link of portlet

thumbnail
Charu Babbar, geändert vor 12 Jahren.

Link of portlet

Regular Member Beiträge: 167 Beitrittsdatum: 13.09.11 Neueste Beiträge
Hi,

I have a custom portlet whose jsp is view.jsp. In that jsp , I wants to make a link by which on the click of that link web content display portlet opens . Plz tell me the appropriate code 4 this work.


Thanks.
thumbnail
Tanweer Ahmed ., geändert vor 1 Jahr.

RE: Link of portlet

Expert Beiträge: 322 Beitrittsdatum: 11.03.10 Neueste Beiträge
Charu Babbar:
Hi,

I have a custom portlet whose jsp is view.jsp. In that jsp , I wants to make a link by which on the click of that link web content display portlet opens . Plz tell me the appropriate code 4 this work.


Thanks.


Hi Charu,

You can create 2 portal pages.Place your portlet on one of the pages and on the other page web content display portlet.From your jsp code call your Portlet's Action method .In this method add this redirection code.
actionResponse.sendRedirect("/web/guest/pageName")


where,
replace guest with the name of your community and
pageName with the name of the portal page where your web content portlet is located.

Hope this helps,
Regards,
Tanweer
mPowerian-BoschLer
thumbnail
Mayur Patel, geändert vor 12 Jahren.

RE: Link of portlet

Expert Beiträge: 358 Beitrittsdatum: 17.11.10 Neueste Beiträge
If you can to create url like this and pass as link,

Portal portal = PortalUtil.getPortal();
viewURL = portal.getLayoutURL(themeDisplay) + "/-/journal_content/56/"
+ articleResource.getGroupId() + "/" + articleResource.getArticleId();

Regards,
Mayur
thumbnail
Charu Babbar, geändert vor 12 Jahren.

RE: Link of portlet

Regular Member Beiträge: 167 Beitrittsdatum: 13.09.11 Neueste Beiträge
Hi Mayur,

What i can import for this?
thumbnail
Charu Babbar, geändert vor 12 Jahren.

RE: Link of portlet

Regular Member Beiträge: 167 Beitrittsdatum: 13.09.11 Neueste Beiträge
what is articleresource?
thumbnail
Mayur Patel, geändert vor 12 Jahren.

RE: Link of portlet

Expert Beiträge: 358 Beitrittsdatum: 17.11.10 Neueste Beiträge
Refer this link
http://www.liferay.com/community/forums/-/message_boards/message/4858629

you can use themedisplay object to get groupId and you can display any article what you want based on articleId what you have
thumbnail
Charu Babbar, geändert vor 12 Jahren.

RE: Link of portlet

Regular Member Beiträge: 167 Beitrittsdatum: 13.09.11 Neueste Beiträge
What is articleResource?
thumbnail
Mayur Patel, geändert vor 12 Jahren.

RE: Link of portlet

Expert Beiträge: 358 Beitrittsdatum: 17.11.10 Neueste Beiträge
articleResource is the object which they created and through which they are getting groupId and articleId , In your case also there should be some object through which you can get groupId(can also use themedisplay object) and articleId(for that you want to link the content).
thumbnail
Charu Babbar, geändert vor 12 Jahren.

RE: Link of portlet

Regular Member Beiträge: 167 Beitrittsdatum: 13.09.11 Neueste Beiträge
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="java.util.*"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%>
<%@page import="javax.portlet.*"%>
<%@page import="javax.portlet.ActionRequest,com.liferay.portlet.journal.model.JournalArticle,com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil"%>

<%@ 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.StringBundler" %>
<%@page import="com.liferay.portal.theme.ThemeDisplay" %>

<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
<%@ page import="com.liferay.portlet.PortletURLFactoryUtil"%>
<%@ page import="com.liferay.portal.kernel.portlet.LiferayPortletURL"%>
<%@ page import="javax.portlet.PortletRequest"%>
<%@ page import="com.liferay.portal.model.Layout"%>


<%@page isELIgnored="false"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<portlet:defineObjects />
<!--
This is the <b>HeaderPortlet</b> portlet in View mode. -->
<body>
<%
JournalArticle jrnl=null;


List<JournalArticle> journalList = new ArrayList<JournalArticle>();
journalList = JournalArticleLocalServiceUtil.getArticles();
System.out.println("[journalList]"+journalList);
System.out.println("[journalList size]"+journalList.size());
List<JournalArticle> contentList = new ArrayList<JournalArticle>();
PortletURL portletURL = renderResponse.createRenderURL();
ThemeDisplay themeDisplay = (ThemeDisplay) request .getAttribute(WebKeys.THEME_DISPLAY);
/*String pathToWebContent = themeDisplay.getPortalURL() + themeDisplay.getPathMain();
String portletName1 = (String)actionRequest.getAttribute(WebKeys.PORTLET_ID);
PortletURL redirectURL =PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(actionRequest), porltetName1,themeDisplay.getLayout().getPlid(), PortletRequest.RENDER_PHASE); */
/* ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(com.liferay.portal.kernel.util.WebKeys.THEME_DISPLAY);
Layout layout = themeDisplay.getLayout();
long plid = layout.getPlid() ;
PortletURL portletURL1= PortletURLFactoryUtil.create(request, "56", plid, PortletRequest.RENDER_PHASE); */
System.out.println("portlet url is:..........................................."+portletURL);


String url=portletURL.toString();
int index=url.indexOf("?");
String url1=url.substring(0,index );
System.out.println("After appending............"+url1);

for(int i = 0; i< journalList.size();i++)
{
if(journalList.get(i).getStatus() == 0){
contentList.add(journalList.get(i));
}
}
System.out.println("[archivedList size]"+contentList.size());
session.setAttribute("archivedList", contentList);

%>

<hgroup>


<% for(int i=0;i<contentList.size();i++)
{
StringBundler articleURL = new StringBundler(20);
articleURL.append(url1);
articleURL.append("?p_p_id=62_INSTANCE_LLy6Jh3StBwr");
articleURL.append("&p_p_lifecycle=0");
articleURL.append("&p_p_state=maximized");
articleURL.append("&p_p_mode=view");
articleURL.append("&p_p_col_id=column-2");
articleURL.append("&p_p_col_pos=2");
articleURL.append("&p_p_col_count=4");
articleURL.append("&_62_INSTANCE_LLy6Jh3StBwr_groupId=");
articleURL.append(contentList.get(i).getGroupId());
articleURL.append("&_62_INSTANCE_LLy6Jh3StBwr_articleId=");
articleURL.append(contentList.get(i).getArticleId());
articleURL.append("&_62_INSTANCE_LLy6Jh3StBwr_version=");
articleURL.append(contentList.get(i).getVersion());

System.out.println("url string is>................:"+articleURL.toString());


%>
<a href="<%=articleURL.toString()%>"> <% out.print(contentList.get(i).getUrlTitle());%></a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% } %>



<%

com.liferay.portal.util.Portal portal = com.liferay.portal.util.PortalUtil.getPortal();
String viewURL = portal.getLayoutURL(themeDisplay) + "/-/journal_content/56/"+ themeDisplay.getGroupId() + "/" + themeDisplay.getArticleId();
%>
<h5>
<a href="<%=%>">Create content Item</a>

</h5>


</hgroup>
</body>
</html>
I wants to open the webcontent display portlet on the click on create content item link,Plz suggest me.....

<html>
thumbnail
Charu Babbar, geändert vor 12 Jahren.

RE: Link of portlet

Regular Member Beiträge: 167 Beitrittsdatum: 13.09.11 Neueste Beiträge
Plz chk the above code....I wants to open the webcontent display portlet on the link of create content item.plz chk it which is in <h5> tag...
thumbnail
Mayur Patel, geändert vor 12 Jahren.

RE: Link of portlet

Expert Beiträge: 358 Beitrittsdatum: 17.11.10 Neueste Beiträge
Hi Charu,

Replace the Following code,

<%

com.liferay.portal.util.Portal portal = com.liferay.portal.util.PortalUtil.getPortal();
String viewURL = portal.getLayoutURL(themeDisplay) + "/-/journal_content/56/"+ themeDisplay.getScopeGroupId() + "/10901";
// 10901 is the articleId that I want to show in webcontent display portlet
%>

<h5>
<a href="<%=viewURL%>">Create content Item</a>
</h5>

but Its showing to me "You do not have the roles required to access this portlet" error in webcontent display portlet , If you can try or any other liferay expert can give idea to this problem.
thumbnail
Charu Babbar, geändert vor 12 Jahren.

RE: Link of portlet

Regular Member Beiträge: 167 Beitrittsdatum: 13.09.11 Neueste Beiträge
Hi ,

Plz chk this code. and give me the solution i will appriciate it.plz suggest..
thumbnail
Sagar A Vyas, geändert vor 12 Jahren.

RE: Link of portlet

Liferay Master Beiträge: 679 Beitrittsdatum: 17.04.09 Neueste Beiträge
Charu Babbar:
Hi ,

Plz chk this code. and give me the solution i will appriciate it.plz suggest..


Hi Charu,

Might below help you.

http://www.liferay.com/community/forums/-/message_boards/view_message/11502392

Thanks,
Sagar Vyas
thumbnail
Charu Babbar, geändert vor 12 Jahren.

RE: Link of portlet

Regular Member Beiträge: 167 Beitrittsdatum: 13.09.11 Neueste Beiträge
Hi Sagar Vyas ,

Thanks 4 replying.I appreciate it. But My requirement is only this: I wants to open a web content display portlet on a click of a link. Plz tell me.

Thanks in advance.

With regards,
Charu
thumbnail
Nagendra Kumar Busam, geändert vor 12 Jahren.

RE: Link of portlet

Liferay Master Beiträge: 678 Beitrittsdatum: 07.07.09 Neueste Beiträge
Can you give more details about your requirement

> I am assuming you have portlet1 (which is having a link to web content display portlet) in page1 & web content display in page2(remeber it's an instanceable portlet) - You need to give portletId of web content display portlet in portlet1 some how (hard code the value of)

When you click on link in portlet1, you need to open web content display portlet in page2 - Is it what you are looking for?
thumbnail
Charu Babbar, geändert vor 12 Jahren.

RE: Link of portlet

Regular Member Beiträge: 167 Beitrittsdatum: 13.09.11 Neueste Beiträge
Thanks to all for responding. It works fine now due to you help.


With regards,

Charu
thumbnail
Mayur Patel, geändert vor 12 Jahren.

RE: Link of portlet

Expert Beiträge: 358 Beitrittsdatum: 17.11.10 Neueste Beiträge
If you can share some info about solution which you got and what problem were you facing in between.
thumbnail
Nagendra Kumar Busam, geändert vor 12 Jahren.

RE: Link of portlet

Liferay Master Beiträge: 678 Beitrittsdatum: 07.07.09 Neueste Beiträge
Please try to make it as a habit (Unless you are very much busy) to post how you got the solution. That way it will be helpful for other community members as well
thumbnail
Sagar A Vyas, geändert vor 12 Jahren.

RE: Link of portlet

Liferay Master Beiträge: 679 Beitrittsdatum: 17.04.09 Neueste Beiträge
Nagendra Kumar Busam:
Please try to make it as a habit (Unless you are very much busy) to post how you got the solution. That way it will be helpful for other community members as well


Hi Charu,

Agree with Nagendra.

Even I am not able to get from where(How) you got the solution from this chain of forum :emoticon

It would be better if you can share solution later on when you get free emoticon

Thanks,
Sagar Vyas
thumbnail
Charu Babbar, geändert vor 12 Jahren.

RE: Link of portlet

Regular Member Beiträge: 167 Beitrittsdatum: 13.09.11 Neueste Beiträge
Hi buddies,

I was using the Render_Phase,In that place i m using now Action_phase.
Thats it...It will works fine.This is the solution.Now I wants directly web content form will be open now.

With Regards,

Charu
thumbnail
Nagendra Kumar Busam, geändert vor 12 Jahren.

RE: Link of portlet

Liferay Master Beiträge: 678 Beitrittsdatum: 07.07.09 Neueste Beiträge
Good job Charu, now you started sharing how you did it.

Can you be more specific like -

add a piece of code & a bit clear explanation (After this much long discussion if you simply say Action Phase instead of Render - not looking good & not helpful to community members as well ), at present state this forum post may not be fully helpful for everybody
thumbnail
Charu Babbar, geändert vor 12 Jahren.

RE: Link of portlet

Regular Member Beiträge: 167 Beitrittsdatum: 13.09.11 Neueste Beiträge
Hi Buddies,

This is the solution for the sameemoticonlz check it here..As per Nagendra Kumar Busam, I m sending here code snippet , I think it will helpful for all of you.
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="java.util.*"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%>
<%@page import="javax.portlet.*"%>
<%@page import="javax.portlet.ActionRequest,com.liferay.portlet.journal.model.JournalArticle,com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil"%>

<%@ 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.StringBundler" %>
<%@page import="com.liferay.portal.theme.ThemeDisplay" %>

<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
<%@ page import="com.liferay.portlet.PortletURLFactoryUtil"%>
<%@ page import="com.liferay.portal.kernel.portlet.LiferayPortletURL"%>
<%@ page import="javax.portlet.PortletRequest"%>
<%@ page import="com.liferay.portal.model.Layout"%>


<%@page isELIgnored="false"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<portlet:defineObjects />
<!--
This is the <b>HeaderPortlet</b> portlet in View mode. -->
<body>
<%
JournalArticle jrnl=null;


List<JournalArticle> journalList = new ArrayList<JournalArticle>();
journalList = JournalArticleLocalServiceUtil.getArticles();
System.out.println("[journalList]"+journalList);
System.out.println("[journalList size]"+journalList.size());
List<JournalArticle> contentList = new ArrayList<JournalArticle>();
PortletURL portletURL = renderResponse.createRenderURL();
ThemeDisplay themeDisplay = (ThemeDisplay) request .getAttribute(WebKeys.THEME_DISPLAY);
/*String pathToWebContent = themeDisplay.getPortalURL() + themeDisplay.getPathMain();
String portletName1 = (String)actionRequest.getAttribute(WebKeys.PORTLET_ID);
PortletURL redirectURL =PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(actionRequest), porltetName1,themeDisplay.getLayout().getPlid(), PortletRequest.RENDER_PHASE); */
/* ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(com.liferay.portal.kernel.util.WebKeys.THEME_DISPLAY);
Layout layout = themeDisplay.getLayout();
long plid = layout.getPlid() ;
PortletURL portletURL1= PortletURLFactoryUtil.create(request, "56", plid, PortletRequest.ACTION_PHASE); */
System.out.println("portlet url is:..........................................."+portletURL);


String url=portletURL.toString();
int index=url.indexOf("?");
String url1=url.substring(0,index );
System.out.println("After appending............"+url1);

for(int i = 0; i< journalList.size();i++)
{
if(journalList.get(i).getStatus() == 0){
contentList.add(journalList.get(i));
}
}
System.out.println("[archivedList size]"+contentList.size());
session.setAttribute("archivedList", contentList);

%>

<hgroup>


<% for(int i=0;i<contentList.size();i++)
{
StringBundler articleURL = new StringBundler(20);
articleURL.append(url1);
articleURL.append("?p_p_id=62_INSTANCE_LLy6Jh3StBwr");
articleURL.append("&p_p_lifecycle=0");
articleURL.append("&p_p_state=maximized");
articleURL.append("&p_p_mode=view");
articleURL.append("&p_p_col_id=column-2");
articleURL.append("&p_p_col_pos=2");
articleURL.append("&p_p_col_count=4");
articleURL.append("&_62_INSTANCE_LLy6Jh3StBwr_groupId=");
articleURL.append(contentList.get(i).getGroupId());
articleURL.append("&_62_INSTANCE_LLy6Jh3StBwr_articleId=");
articleURL.append(contentList.get(i).getArticleId());
articleURL.append("&_62_INSTANCE_LLy6Jh3StBwr_version=");
articleURL.append(contentList.get(i).getVersion());

System.out.println("url string is>................:"+articleURL.toString());


%>
<a href="<%=articleURL.toString()%>"> <% out.print(contentList.get(i).getUrlTitle());%></a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% } %>



<%

com.liferay.portal.util.Portal portal = com.liferay.portal.util.PortalUtil.getPortal();
String viewURL = portal.getLayoutURL(themeDisplay) + "/-/journal_content/56/"+ themeDisplay.getGroupId() + "/" + themeDisplay.getArticleId();
%>
<h5>
<a href="<%=%>">Create content Item</a>

</h5>


</hgroup>
</body>
</html>
Hey Guys, Now I am doing this same with custom field...Any suggestions are acceptable..So plz share some more information here.

Thanks all,
With regards,
Charu
thumbnail
Sagar A Vyas, geändert vor 12 Jahren.

RE: Link of portlet

Liferay Master Beiträge: 679 Beitrittsdatum: 17.04.09 Neueste Beiträge
Hi Charu,

First Of all thanks for sharing this.

And one more free suggestion when you share any solution for forum use control in forum which will increase readability on your solution. emoticon

Please find attached screen shot in case if you dont know how to do it emoticon

Thanks,
Sagar Vyas
thumbnail
Nagendra Kumar Busam, geändert vor 12 Jahren.

RE: Link of portlet

Liferay Master Beiträge: 678 Beitrittsdatum: 07.07.09 Neueste Beiträge
First of all thanks once again for sharing your code. You can format the same (even deleted commented portions if any) by editing as suggested by Sagar

Have you added any custom fields to Journal Article. How you want it to be displayed?
thumbnail
Charu Babbar, geändert vor 12 Jahren.

RE: Link of portlet

Regular Member Beiträge: 167 Beitrittsdatum: 13.09.11 Neueste Beiträge
Hi,

I have added the 1 custom field which is true and false.
thumbnail
Nagendra Kumar Busam, geändert vor 12 Jahren.

RE: Link of portlet

Liferay Master Beiträge: 678 Beitrittsdatum: 07.07.09 Neueste Beiträge
custom field for Journal Article - which can have boolean value?
thumbnail
Charu Babbar, geändert vor 12 Jahren.

RE: Link of portlet

Regular Member Beiträge: 167 Beitrittsdatum: 13.09.11 Neueste Beiträge
hi,

I have made one with named checked
thumbnail
Nagendra Kumar Busam, geändert vor 12 Jahren.

RE: Link of portlet

Liferay Master Beiträge: 678 Beitrittsdatum: 07.07.09 Neueste Beiträge
I got what you are saying - you have added one custom field named checked (boolean) to JournalArticle

What is your requirement? What you trying to do?
thumbnail
Charu Babbar, geändert vor 12 Jahren.

RE: Link of portlet

Regular Member Beiträge: 167 Beitrittsdatum: 13.09.11 Neueste Beiträge
Hi

Telling you all the things:
When I checked that field,at the time of publishing the content Then I wants all the list of the contents which are checked at the time of publishing content .this list i wants to populate in custom portlet.Thats be my requirement.Plz help ....


Thanks,

With Regards,

Charu