2012-10-18 79 views
0

我有一個Liferay應用程序,其中用戶有一個「會員計劃」。當用戶登錄時,我需要檢查他們的會員計劃是否已過期並向他們顯示警告消息。 (會員計劃獨立於登錄功能,即使他/她的會員計劃已過期,用戶仍可以登錄)。登錄後向用戶顯示一條警告消息

我想創建一個登錄後操作。但是我無法訪問我的服務構建器方法(MemberPlanLocalServiceUtil.isPlanExpired()),或者我創建的任何其他鉤子。

我應該用什麼方法來解決這個問題?這裏需要一個ext插件嗎?還是我可以做別的事情?

回答

0

我最終解決了這個問題。 (這是在哪裏被需要迅速解決這些情形之一,和骯髒的解決方案,它是)

這裏就是我所做的

我添加了一個LoginAction我在其中設置會話屬性:

public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException { 
     HttpSession session = request.getSession(); 
     session.setAttribute("LIFERAY_SHARED_checkMemberExpiry", true); 
} 

然後,在主頁上的portlet中,檢查是否設置了此會話屬性,並在需要時顯示我的警告消息。

0

可以使用applicationContext.xml實現,在WEB-INF中創建一個applicationContext.xml,將所有的bean引用放入它中。 在Web.xml和偵聽器類中設置上下文參數。

環境參數

<context-param> 
    <param-name>portalContextConfigLocation</param-name> 
    <param-value>/WEB-INF/applicationContext.xml</param-value> 
</context-param> 

監聽器類

<listener> 
    <listener-class>com.liferay.portal.kernel.spring.context.PortletContextLoaderListener</listener-class> 
</listener> 
<listener> 
    <listener-class>com.liferay.portal.kernel.servlet.SerializableSessionAttributeListener</listener-class> 
</listener> 
<listener> 
    <listener-class>com.liferay.portal.kernel.servlet.HookContextListener</listener-class> 
</listener> 

僅供參考,您可以檢查這個帖子 http://www.liferay.com/zh/web/raymond.auge/blog/-/blogs/custom-velocity-tools-and-liferay-6-0