Thursday, 20 August 2015

Displaying the web content article in popup

1. First Create a folder structure under docroot like /html/article and create two jsps named as                 articlePopUp.jsp and articleContent.jsp under the article folder.
2. Place necessary tag libraries and imports in the two jsps.
3. Place the following code in the articlePopUp.jsp file
<portlet:renderURL var="articleRenderURL" windowState=" <%=LiferayWindowState.EXCLUSIVE.toString()%>">
   <portlet:param name="jspPage" value="/html/article/articleContent.jsp"/>
</portlet:renderURL>
<%
long articleIdValue=12345;
%>
<a  href="javascript:void(0);" id='<%=articleIdValue %>'  onclick='getDetails(this.id);'>Click here </a>
<aui:script>
  function getDetails(idValue){   
try{
 var url='<%=articleRenderURL.toString()%>' + '&<portlet:namespace />idValue=' + idValue;
    Liferay.Util.openWindow({dialog: {width:800.05,height:540.55,destroyOnHide: true},
  cache: false,
  id: 'openPopup',
  title: 'Article Description',
  uri: url
  });   
}catch(e){
  alert(e);
  } }
  </aui:script> 
4. Place the following code in the articlecontent.jsp file
<%
String idValue=(String)renderRequest.getParameter("idValue");
%>
  <div><liferay-ui:journal-article articleId="<%=idValue%>" groupId="<%= themeDisplay.getLayout().getGroupId() %>"/></div>