Fórum

Common Error liferay page per community

giribabu sanapala, modificado 10 Anos atrás.

Common Error liferay page per community

New Member Postagens: 18 Data de Entrada: 06/03/12 Postagens Recentes
Hi Team,
I am using Liferay 6.1.1-CE-GA2 version. i have requirement like i have one error page per each site if any request resoure is not avaliable or user role doesn't have access that time i have to redirect to error page of that site.

Senario:

i have two sites : ADR, CT
in ADR i have error page called ADRNASU (public hidden page) so if any error occurs in ADR i have to redirect ADRNASU page
in CT i have CTNASU(public hidden page) so if any error i have to redirect CTNASU page.

if any one done same kind of requriment please tell me how to do, and any approach, suggestions would be help full.

thanks in advance. please help me out, it's very urgent

Regards,
Giri
thumbnail
Apoorva Prakash, modificado 10 Anos atrás.

RE: Common Error liferay page per community

Liferay Master Postagens: 658 Data de Entrada: 15/06/10 Postagens Recentes
giribabu sanapala:
Hi Team,
I am using Liferay 6.1.1-CE-GA2 version. i have requirement like i have one error page per each site if any request resoure is not avaliable or user role doesn't have access that time i have to redirect to error page of that site.

Senario:

i have two sites : ADR, CT
in ADR i have error page called ADRNASU (public hidden page) so if any error occurs in ADR i have to redirect ADRNASU page
in CT i have CTNASU(public hidden page) so if any error i have to redirect CTNASU page.

if any one done same kind of requriment please tell me how to do, and any approach, suggestions would be help full.

thanks in advance. please help me out, it's very urgent

Regards,
Giri


Hi Giri,

See this thread: http://www.liferay.com/community/forums/-/message_boards/message/11279721

HTH.
giribabu sanapala, modificado 9 Anos atrás.

RE: Common Error liferay page per community

New Member Postagens: 18 Data de Entrada: 06/03/12 Postagens Recentes
Hi All ,
i achieved this as below. done in 6.1.1 CE GA2 version
step 1:
add following property in portal-ext.properties file
layout.friendly.url.page.not.found=/errors/404-ErrorHandler.jsp
step 2:
in \custom_jsps create folder called errors(\custom_jsps\errors)
copy paste 404 jsp which liferay by default provide.then rename it to 404-ErrorHandler.jsp

step 3:

create a hidden page in all liferay sites (eg. error page)

step 4:
copy paste below code in 404-ErrorHandler.jsp file.

<%@ page import="com.liferay.portal.util.WebKeys" %>
<%@ page import="com.liferay.portal.model.LayoutSet" %>
<%@ page import="com.liferay.portal.service.LayoutLocalServiceUtil"%>
<%@ page import="com.liferay.portal.NoSuchLayoutException"%>
<%@ page import="com.liferay.portal.util.PortalUtil"%>
<%@ page import="com.liferay.portal.kernel.log.Log" %>
<%@ page import="com.liferay.portal.kernel.log.LogFactoryUtil" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ include file="../html/common/init.jsp" %>
<portlet:defineObjects />
<%!
//Initialize logger
private static Log LOGGER = LogFactoryUtil.getLog("404-ErrorHandler.jsp");
%>

<%

String url = PortalUtil.getCurrentURL(request);

LOGGER.info("noSuchResourceException ::" + url);
String contextPath = PortalUtil.getPathContext();
//String friendlyURL = contextPath+"/web/guest/nasu";
String friendlyURL = "";
String currentURL = PortalUtil.getCurrentURL(request);
String[] tokens = currentURL.split("/");

StringBuffer redirectURL = new StringBuffer(PortalUtil.getPortalURL(request));

if(contextPath.length() > 1){

redirectURL.append(contextPath);
redirectURL.append("/web");

if(tokens.length > 3){
friendlyURL = "/"+tokens[3];
}
}else{

redirectURL.append("/web");

if(tokens.length > 2){
friendlyURL = "/"+tokens[2];
}
}

LOGGER.info("friendlyURL ::" + friendlyURL);

boolean isNasu = true;

try {
Group group = GroupLocalServiceUtil.getFriendlyURLGroup(PortalUtil.getCompanyId(request), friendlyURL);

LayoutLocalServiceUtil.getFriendlyURLLayout(group.getGroupId(), false, "/errorpage");

redirectURL.append(group.getFriendlyURL());
redirectURL.append("/nasu");
url = redirectURL.toString();
LOGGER.info("url ::" + redirectURL );
response.sendRedirect(url);
} catch (Exception e) {
isNasu = false;
}
%>