2012-01-30 60 views
8

我使用的是Liferay 6.0。我有多個組織,希望根據組織改變用戶的着陸頁。Liferay:根據組織改變用戶登錄頁面

我是Liferay的新手,試圖找到一些建議,但找不到正確的答案。

是否可以使用開箱即用的工具?無需編寫代碼?

如果需要代碼,什麼是最佳解決方案?

請幫幫忙, 謝謝

回答

7

在Liferay的6 default landing page可以與物業default.landing.page.path進行設置,但它是影響門戶實例每個用戶的一般設置。

要根據組織更改用戶的登錄頁面,需要使用"post login" portal event的自定義操作。最終,login.events.post擁有的財產,以指向自定義登錄操作:

login.events.post=yourcode.CustomLandingPageAction 

有實現這個兩個選項:

使組織的用戶登陸的自定義操作e組織的私人頁面(源自以上鍊接):

public class CustomLandingPageAction extends Action { 

    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException { 
      try { 
        doRun(request, response); 
      } catch (Exception e) { 
        throw new ActionException(e); 
      } 
    } 

    protected void doRun(HttpServletRequest request, HttpServletResponse response) 
      throws Exception { 

     long companyId = PortalUtil.getCompanyId(request); 
     String path = PrefsPropsUtil.getString(companyId, PropsKeys.DEFAULT_LANDING_PAGE_PATH);; 

     if (Validator.isNull(path)) { 
      User user = PortalUtil.getUser(request); 
      String language = user.getLocale().getLanguage(); 
      List<Organization> orgList = OrganizationLocalServiceUtil.getUserOrganizations(user.getUserId()); 

      // Default landing page: go to the path in DefaultLandingPageAction 
      LastPath lastPath = new LastPath(StringPool.BLANK, path, new HashMap<String, String[]>()); 

      // But if the logged user is in some community 
      if (!orgList.isEmpty()){ 
       // and such community has a private page 
       if (orgList.get(0).hasPrivateLayouts()) { 
        // go there instead 
        String orgFriendlyURL = orgList.get(0).getGroup().getFriendlyURL(); 
        String myPath = "/" + language + "/group" + orgFriendlyURL; 

        lastPath = new LastPath(StringPool.BLANK, myPath); 
       } 
      } 

      HttpSession session = request.getSession();       
      session.setAttribute(WebKeys.LAST_PATH, lastPath); 
     } 
    } 
} 
+0

非常感謝您的快速回復。 這是我做的: – 2012-01-31 16:44:57

相關問題